Rename extract::Body to extract::RawBody (#233)

This commit is contained in:
David Pedersen 2021-08-21 20:04:39 +02:00 committed by GitHub
parent fbd43c6600
commit add3dc36f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 7 deletions

View File

@ -51,6 +51,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
`tower::make::Shared` ([#229](https://github.com/tokio-rs/axum/pull/229)) `tower::make::Shared` ([#229](https://github.com/tokio-rs/axum/pull/229))
- All usage of `tower::BoxError` has been replaced with `axum::BoxError` ([#229](https://github.com/tokio-rs/axum/pull/229)) - All usage of `tower::BoxError` has been replaced with `axum::BoxError` ([#229](https://github.com/tokio-rs/axum/pull/229))
- `tower::util::Either` no longer implements `IntoResponse` ([#229](https://github.com/tokio-rs/axum/pull/229)) - `tower::util::Either` no longer implements `IntoResponse` ([#229](https://github.com/tokio-rs/axum/pull/229))
- `extract::Body` has been renamed to `extract::RawBody` to avoid conflicting
with `body::Body`
- These future types have been moved - These future types have been moved
- `extract::extractor_middleware::ExtractorMiddlewareResponseFuture` moved - `extract::extractor_middleware::ExtractorMiddlewareResponseFuture` moved
to `extract::extractor_middleware::future::ResponseFuture` ([#133](https://github.com/tokio-rs/axum/pull/133)) to `extract::extractor_middleware::future::ResponseFuture` ([#133](https://github.com/tokio-rs/axum/pull/133))

View File

@ -254,7 +254,7 @@
//! "/body", //! "/body",
//! // `extract::Body` defaults to `axum::body::Body` //! // `extract::Body` defaults to `axum::body::Body`
//! // but can be customized //! // but can be customized
//! get(|_: extract::Body<MyBody<Body>>| async {}) //! get(|_: extract::RawBody<MyBody<Body>>| async {})
//! ) //! )
//! .route( //! .route(
//! "/body-stream", //! "/body-stream",
@ -310,7 +310,7 @@ pub use self::{
query::Query, query::Query,
raw_query::RawQuery, raw_query::RawQuery,
request_parts::OriginalUri, request_parts::OriginalUri,
request_parts::{Body, BodyStream}, request_parts::{BodyStream, RawBody},
}; };
#[doc(no_inline)] #[doc(no_inline)]
pub use crate::Json; pub use crate::Json;

View File

@ -46,7 +46,7 @@ where
} }
#[async_trait] #[async_trait]
impl<B> FromRequest<B> for Body<B> impl<B> FromRequest<B> for RawBody<B>
where where
B: Send, B: Send,
{ {
@ -219,19 +219,19 @@ where
} }
} }
/// Extractor that extracts the request body. /// Extractor that extracts the raw request body.
/// ///
/// # Example /// # Example
/// ///
/// ```rust,no_run /// ```rust,no_run
/// use axum::{ /// use axum::{
/// extract::Body, /// extract::RawBody,
/// handler::get, /// handler::get,
/// Router, /// Router,
/// }; /// };
/// use futures::StreamExt; /// use futures::StreamExt;
/// ///
/// async fn handler(Body(body): Body) { /// async fn handler(RawBody(body): RawBody) {
/// // ... /// // ...
/// } /// }
/// ///
@ -241,7 +241,7 @@ where
/// # }; /// # };
/// ``` /// ```
#[derive(Debug, Default, Clone)] #[derive(Debug, Default, Clone)]
pub struct Body<B = crate::body::Body>(pub B); pub struct RawBody<B = crate::body::Body>(pub B);
#[async_trait] #[async_trait]
impl<B> FromRequest<B> for Bytes impl<B> FromRequest<B> for Bytes