|
5 | 5 | //! [`axum::extract`]: https://docs.rs/axum/latest/axum/extract/index.html
|
6 | 6 |
|
7 | 7 | use self::rejection::*;
|
8 |
| -use crate::{body::BoxBody, response::IntoResponse, BoxError}; |
| 8 | +use crate::{body::Body, response::IntoResponse, BoxError}; |
9 | 9 | use async_trait::async_trait;
|
10 | 10 | use bytes::Bytes;
|
11 |
| -use http::{Extensions, HeaderMap, Method, Uri, Version}; |
| 11 | +use http::{Extensions, HeaderMap, Method, Request, Uri, Version}; |
12 | 12 | use std::convert::Infallible;
|
13 | 13 |
|
14 | 14 | pub mod rejection;
|
15 | 15 |
|
16 | 16 | mod request_parts;
|
17 | 17 | mod tuple;
|
18 | 18 |
|
19 |
| -/// Type alias for [`http::Request`] whose body type defaults to [`BoxBody`], the most common body |
20 |
| -/// type used with axum. |
21 |
| -pub type Request<T = BoxBody> = http::Request<T>; |
22 |
| - |
23 | 19 | /// Types that can be created from requests.
|
24 | 20 | ///
|
25 | 21 | /// See [`axum::extract`] for more details.
|
@@ -84,7 +80,7 @@ pub struct RequestParts {
|
84 | 80 | version: Version,
|
85 | 81 | headers: HeaderMap,
|
86 | 82 | extensions: Extensions,
|
87 |
| - body: Option<BoxBody>, |
| 83 | + body: Option<Body>, |
88 | 84 | }
|
89 | 85 |
|
90 | 86 | impl RequestParts {
|
@@ -112,15 +108,13 @@ impl RequestParts {
|
112 | 108 | body,
|
113 | 109 | ) = req.into_parts();
|
114 | 110 |
|
115 |
| - let body = crate::body::boxed(body); |
116 |
| - |
117 | 111 | RequestParts {
|
118 | 112 | method,
|
119 | 113 | uri,
|
120 | 114 | version,
|
121 | 115 | headers,
|
122 | 116 | extensions,
|
123 |
| - body: Some(body), |
| 117 | + body: Some(Body::wrap_body(body)), |
124 | 118 | }
|
125 | 119 | }
|
126 | 120 |
|
@@ -165,7 +159,7 @@ impl RequestParts {
|
165 | 159 | /// been called.
|
166 | 160 | ///
|
167 | 161 | /// [`take_body`]: RequestParts::take_body
|
168 |
| - pub fn try_into_request(self) -> Result<Request<BoxBody>, BodyAlreadyExtracted> { |
| 162 | + pub fn try_into_request(self) -> Result<Request<Body>, BodyAlreadyExtracted> { |
169 | 163 | let Self {
|
170 | 164 | method,
|
171 | 165 | uri,
|
@@ -243,20 +237,20 @@ impl RequestParts {
|
243 | 237 | /// Gets a reference to the request body.
|
244 | 238 | ///
|
245 | 239 | /// Returns `None` if the body has been taken by another extractor.
|
246 |
| - pub fn body(&self) -> Option<&BoxBody> { |
| 240 | + pub fn body(&self) -> Option<&Body> { |
247 | 241 | self.body.as_ref()
|
248 | 242 | }
|
249 | 243 |
|
250 | 244 | /// Gets a mutable reference to the request body.
|
251 | 245 | ///
|
252 | 246 | /// Returns `None` if the body has been taken by another extractor.
|
253 | 247 | // this returns `&mut Option<B>` rather than `Option<&mut B>` such that users can use it to set the body.
|
254 |
| - pub fn body_mut(&mut self) -> &mut Option<BoxBody> { |
| 248 | + pub fn body_mut(&mut self) -> &mut Option<Body> { |
255 | 249 | &mut self.body
|
256 | 250 | }
|
257 | 251 |
|
258 | 252 | /// Takes the body out of the request, leaving a `None` in its place.
|
259 |
| - pub fn take_body(&mut self) -> Option<BoxBody> { |
| 253 | + pub fn take_body(&mut self) -> Option<Body> { |
260 | 254 | self.body.take()
|
261 | 255 | }
|
262 | 256 | }
|
|
0 commit comments