@@ -12,7 +12,7 @@ use std::{
12
12
pin:: Pin ,
13
13
task:: { ready, Context , Poll } ,
14
14
} ;
15
- use tower_service :: Service ;
15
+ use tower :: { Service , ServiceExt } ;
16
16
17
17
/// A [`Service`] router.
18
18
#[ derive( Debug , Default , Clone ) ]
@@ -77,7 +77,7 @@ impl Routes {
77
77
{
78
78
self . router = self . router . route_service (
79
79
& format ! ( "/{}/*rest" , S :: NAME ) ,
80
- AxumBodyService { service : svc } ,
80
+ svc . map_request ( | req : Request < axum :: body :: Body > | req . map ( boxed ) ) ,
81
81
) ;
82
82
self
83
83
}
@@ -143,32 +143,3 @@ impl Future for RoutesFuture {
143
143
}
144
144
}
145
145
}
146
-
147
- #[ derive( Clone ) ]
148
- struct AxumBodyService < S > {
149
- service : S ,
150
- }
151
-
152
- type BoxFuture < ' a , T > = Pin < Box < dyn Future < Output = T > + Send + ' a > > ;
153
-
154
- impl < S > Service < Request < axum:: body:: Body > > for AxumBodyService < S >
155
- where
156
- S : Service < Request < BoxBody > , Response = Response < BoxBody > , Error = Infallible >
157
- + Clone
158
- + Send
159
- + ' static ,
160
- S :: Future : Send + ' static ,
161
- {
162
- type Response = Response < axum:: body:: Body > ;
163
- type Error = Infallible ;
164
- type Future = BoxFuture < ' static , Result < Self :: Response , Self :: Error > > ;
165
-
166
- fn poll_ready ( & mut self , cx : & mut Context < ' _ > ) -> Poll < Result < ( ) , Self :: Error > > {
167
- self . service . poll_ready ( cx)
168
- }
169
-
170
- fn call ( & mut self , req : Request < axum:: body:: Body > ) -> Self :: Future {
171
- let fut = self . service . call ( req. map ( boxed) ) ;
172
- Box :: pin ( async move { fut. await . map ( |res| res. map ( axum:: body:: Body :: new) ) } )
173
- }
174
- }
0 commit comments