@@ -10,14 +10,14 @@ use crate::{
10
10
router:: { Resource , Router } ,
11
11
Request ,
12
12
extract:: Extract ,
13
- RouteMatch ,
14
- Response ,
13
+ RouteMatch ,
14
+ Response ,
15
15
body:: Body ,
16
16
Middleware ,
17
17
} ;
18
18
19
19
/// The top-level type for setting up a Tide application.
20
- ///
20
+ ///
21
21
/// Apps are equipped with a handle to their own state (`Data`), which is available to all endpoints.
22
22
/// This is a "handle" because it must be `Clone`, and endpoints are invoked with a fresh clone.
23
23
/// They also hold a top-level router.
@@ -57,7 +57,7 @@ impl<Data: Clone + Send + Sync + 'static> App<Data> {
57
57
}
58
58
59
59
/// Start serving the app at the given address.
60
- ///
60
+ ///
61
61
/// Blocks the calling thread indefinitely.
62
62
pub fn serve < A : std:: net:: ToSocketAddrs > ( self , addr : A ) {
63
63
let server: Server < Data > = self . into_server ( ) ;
@@ -66,7 +66,7 @@ impl<Data: Clone + Send + Sync + 'static> App<Data> {
66
66
let addr = addr. to_socket_addrs ( ) . unwrap ( ) . next ( ) . unwrap ( ) ;
67
67
68
68
let server = hyper:: Server :: bind ( & addr) . serve ( move || {
69
- let res: Result < _ , std:: io:: Error > = Ok ( server. clone ( ) ) ;
69
+ let res: Result < _ , std:: io:: Error > = Ok ( server. clone ( ) ) ;
70
70
res
71
71
} ) . compat ( ) . map ( |_| {
72
72
let res: Result < ( ) , ( ) > = Ok ( ( ) ) ;
@@ -94,17 +94,17 @@ impl<Data: Clone + Send + Sync + 'static> Service for Server<Data> {
94
94
let router = self . router . clone ( ) ;
95
95
let middleware = self . middleware . clone ( ) ;
96
96
97
- let mut req = req. map ( Body :: from) ;
97
+ let mut req = req. map ( Body :: from) ;
98
98
let path = req. uri ( ) . path ( ) . to_owned ( ) ;
99
99
let method = req. method ( ) . to_owned ( ) ;
100
100
101
- FutureObj :: new ( Box :: new ( async move {
102
- if let Some ( ( endpoint, params) ) = router. route ( & path, & method) {
101
+ FutureObj :: new ( Box :: new ( async move {
102
+ if let Some ( ( endpoint, params) ) = router. route ( & path, & method) {
103
103
for m in middleware. iter ( ) {
104
104
match await ! ( m. request( & mut data, req, & params) ) {
105
105
Ok ( new_req) => req = new_req,
106
106
Err ( resp) => return Ok ( resp. map ( Into :: into) ) ,
107
- }
107
+ }
108
108
}
109
109
110
110
let ( head, mut resp) = await ! ( endpoint. call( data. clone( ) , req, params) ) ;
@@ -122,7 +122,7 @@ impl<Data: Clone + Send + Sync + 'static> Service for Server<Data> {
122
122
}
123
123
124
124
/// An extractor for accessing app data.
125
- ///
125
+ ///
126
126
/// Endpoints can use `AppData<T>` to gain a handle to the data (of type `T`) originally injected into their app.
127
127
pub struct AppData < T > ( pub T ) ;
128
128
@@ -147,4 +147,4 @@ impl<T: Clone + Send + 'static> Extract<T> for AppData<T> {
147
147
) -> Self :: Fut {
148
148
future:: ok ( AppData ( data. clone ( ) ) )
149
149
}
150
- }
150
+ }
0 commit comments