Fix out of date docs for Json (#871)

Fixes https://github.com/tokio-rs/axum/issues/865
This commit is contained in:
David Pedersen 2022-03-19 01:24:28 +01:00 committed by GitHub
parent 437fe5b931
commit 2c985246ba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -15,9 +15,16 @@ use std::ops::{Deref, DerefMut};
/// JSON Extractor / Response.
///
/// When used as an extractor, it can deserialize request bodies into some type that
/// implements [`serde::Deserialize`]. If the request body cannot be parsed, or it does not contain
/// the `Content-Type: application/json` header, it will reject the request and return a
/// `400 Bad Request` response.
/// implements [`serde::Deserialize`]. The request will be rejected (and a [`JsonRejection`] will
/// be returned) if:
///
/// - The request doesn't have a `Content-Type: application/json` (or similar) header.
/// - The body doesn't contain syntactically valid JSON.
/// - The body contains syntactically valid JSON but it couldn't be deserialized into the target
/// type.
/// - Buffering the request body fails.
///
/// See [`JsonRejection`] for more details.
///
/// # Extractor example
///