mirror of
https://github.com/tokio-rs/axum.git
synced 2026-08-21 00:00:14 +02:00
Make JSON and HTTP1 support optional (#286)
* Make json support an optional feature * Fix Json type documentation * Make hyper's http1 feature optional
This commit is contained in:
@@ -192,6 +192,7 @@ pub use self::{
|
||||
request_parts::{BodyStream, RawBody},
|
||||
};
|
||||
#[doc(no_inline)]
|
||||
#[cfg(feature = "json")]
|
||||
pub use crate::Json;
|
||||
|
||||
#[cfg(feature = "multipart")]
|
||||
|
||||
@@ -25,9 +25,11 @@ define_rejection! {
|
||||
pub struct HeadersAlreadyExtracted;
|
||||
}
|
||||
|
||||
#[cfg(feature = "json")]
|
||||
define_rejection! {
|
||||
#[status = BAD_REQUEST]
|
||||
#[body = "Failed to parse the request body as JSON"]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "json")))]
|
||||
/// Rejection type for [`Json`](super::Json).
|
||||
pub struct InvalidJsonBody(Error);
|
||||
}
|
||||
@@ -199,11 +201,13 @@ composite_rejection! {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "json")]
|
||||
composite_rejection! {
|
||||
/// Rejection used for [`Json`](super::Json).
|
||||
///
|
||||
/// Contains one variant for each way the [`Json`](super::Json) extractor
|
||||
/// can fail.
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "json")))]
|
||||
pub enum JsonRejection {
|
||||
InvalidJsonBody,
|
||||
MissingJsonContentType,
|
||||
|
||||
Reference in New Issue
Block a user