mirror of
https://github.com/tokio-rs/axum.git
synced 2024-12-28 23:38:20 +01:00
Re-export more body utilities (#162)
Useful when implementing `IntoResponse`
This commit is contained in:
parent
b4bdddf9d2
commit
b75b7b0184
3 changed files with 16 additions and 10 deletions
|
@ -1,14 +1,17 @@
|
|||
//! HTTP body utilities.
|
||||
|
||||
use crate::Error;
|
||||
use bytes::Bytes;
|
||||
use tower::BoxError;
|
||||
|
||||
#[doc(no_inline)]
|
||||
pub use http_body::Body as HttpBody;
|
||||
pub use http_body::{Body as HttpBody, Empty, Full};
|
||||
|
||||
#[doc(no_inline)]
|
||||
pub use hyper::body::Body;
|
||||
|
||||
#[doc(no_inline)]
|
||||
pub use bytes::Bytes;
|
||||
|
||||
/// A boxed [`Body`] trait object.
|
||||
///
|
||||
/// This is used in axum as the response body type for applications. Its
|
||||
|
|
|
@ -82,7 +82,7 @@ where
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use axum::{prelude::*, extract::NestedUri, http::Uri};
|
||||
/// use axum::{prelude::*, routing::nest, extract::NestedUri, http::Uri};
|
||||
///
|
||||
/// let api_routes = route(
|
||||
/// "/users",
|
||||
|
|
|
@ -89,17 +89,20 @@ pub trait IntoResponse {
|
|||
/// Unless you're implementing this trait for a custom body type, these are
|
||||
/// some common types you can use:
|
||||
///
|
||||
/// - [`hyper::Body`]: A good default that supports most use cases.
|
||||
/// - [`http_body::Empty<Bytes>`]: When you know your response is always
|
||||
/// - [`hyper::Body`]: A good default that supports most use cases. This is
|
||||
/// also re-exported as [`axum::body::Body`].
|
||||
/// - [`axum::body::Empty<Bytes>`]: When you know your response is always
|
||||
/// empty.
|
||||
/// - [`http_body::Full<Bytes>`]: When you know your response always
|
||||
/// - [`axum::body::Full<Bytes>`]: When you know your response always
|
||||
/// contains exactly one chunk.
|
||||
/// - [`BoxBody`]: If you need to unify multiple body types into one, or
|
||||
/// return a body type that cannot be named. Can be created with
|
||||
/// - [`axum::body::BoxBody`]: If you need to unify multiple body types into
|
||||
/// one, or return a body type that cannot be named. Can be created with
|
||||
/// [`box_body`].
|
||||
///
|
||||
/// [`http_body::Empty<Bytes>`]: http_body::Empty
|
||||
/// [`http_body::Full<Bytes>`]: http_body::Full
|
||||
/// [`axum::body::Body`]: crate::body::Body
|
||||
/// [`axum::body::Empty<Bytes>`]: crate::body::Empty
|
||||
/// [`axum::body::Full<Bytes>`]: crate::body::Full
|
||||
/// [`axum::body::BoxBody`]: crate::body::BoxBody
|
||||
type Body: http_body::Body<Data = Bytes, Error = Self::BodyError> + Send + Sync + 'static;
|
||||
|
||||
/// The error type `Self::Body` might generate.
|
||||
|
|
Loading…
Reference in a new issue