mirror of
https://github.com/tokio-rs/axum.git
synced 2026-08-27 00:00:24 +02:00
Make extractors easier to write (#36)
Previously extractors worked directly on `Request<B>` which meant you had to do weird tricks like `mem::take(req.headers_mut())` to get owned parts of the request. This changes that instead to use a new `RequestParts` type that have methods to "take" each part of the request. Without having to do weird tricks. Also removed the need to have `B: Default` for body extractors.
This commit is contained in:
+2
-2
@@ -87,7 +87,7 @@
|
||||
//! [load shed]: tower::load_shed
|
||||
|
||||
use crate::{
|
||||
body::BoxBody,
|
||||
body::{box_body, BoxBody},
|
||||
response::IntoResponse,
|
||||
routing::{EmptyRouter, MethodFilter, RouteFuture},
|
||||
};
|
||||
@@ -656,7 +656,7 @@ where
|
||||
|
||||
fn poll(self: std::pin::Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||
let res = ready!(self.project().0.poll(cx))?;
|
||||
let res = res.map(BoxBody::new);
|
||||
let res = res.map(box_body);
|
||||
Poll::Ready(Ok(res))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user