Repository: actix/actix-web
File: src/types/json.rs (Rust)

Code before:
                }
                Ok(data) => Ok(Json(data)),
            })
            .boxed_local()
    }
}

/// Json extractor configuration
///
/// # Examples
///
/// ```rust
/// use actix_web::{error, web, App, FromRequest, HttpRequest, HttpResponse};
/// use serde_derive::Deserialize;
///
/// #[derive(Deserialize)]
/// struct Info {
///     username: String,
/// }
///
/// /// deserialize `Info` from request's body, max payload size is 4kb
/// async fn index(info: web::Json<Info>) -> String {
///     format!("Welcome {}!", info.username)
/// }
///
/// /// Create custom error response
///
/// /// Return either a 400 or 415, and include the error message from serde
/// /// in the response body
/// fn json_error_handler(err: error::JsonPayloadError, _req: &HttpRequest) -> error::Error {
///     let detail = err.to_string();
///     let response = match &err {
///         error::JsonPayloadError::ContentType => {
///             HttpResponse::UnsupportedMediaType().content_type("text/plain").body(detail)
///         }
///         _ => HttpResponse::BadRequest().content_type("text/plain").body(detail),
///     };
///     error::InternalError::from_response(err, response).into()
/// }
///
/// fn main() {
///     let app = App::new().service(
///         web::resource("/index.html")
///             .app_data(
///                 // change json extractor configuration
///                 web::Json::<Info>::configure(|cfg| {
///                     cfg.limit(4096)
///                        .content_type(|mime| {  // <- accept text/plain content type
///                            mime.type_() == mime::TEXT && mime.subtype() == mime::PLAIN
///                        })
///                        .error_handler(json_error_handler)  // Use our custom error response

Review comment (suggestion):
This doc comment doesn't explain any items, I think it can be removed since later comment explains details.

Code after:
                }
                Ok(data) => Ok(Json(data)),
            })
            .boxed_local()
    }
}

/// Json extractor configuration
///
/// # Examples
///
/// ```rust
/// use actix_web::{error, web, App, FromRequest, HttpRequest, HttpResponse};
/// use serde_derive::Deserialize;
///
/// #[derive(Deserialize)]
/// struct Info {
///     username: String,
/// }
///
/// /// deserialize `Info` from request's body, max payload size is 4kb
/// async fn index(info: web::Json<Info>) -> String {
///     format!("Welcome {}!", info.username)
/// }
///
/// /// Return either a 400 or 415, and include the error message from serde
/// /// in the response body
/// fn json_error_handler(err: error::JsonPayloadError, _req: &HttpRequest) -> error::Error {
///     let detail = err.to_string();
///     let response = match &err {
///         error::JsonPayloadError::ContentType => {
///             HttpResponse::UnsupportedMediaType().content_type("text/plain").body(detail)
///         }
///         _ => HttpResponse::BadRequest().content_type("text/plain").body(detail),
///     };
///     error::InternalError::from_response(err, response).into()
/// }
///
/// fn main() {
///     let app = App::new().service(
///         web::resource("/index.html")
///             .app_data(
///                 // change json extractor configuration
///                 web::Json::<Info>::configure(|cfg| {
///                     cfg.limit(4096)
///                        .content_type(|mime| {  // <- accept text/plain content type
///                            mime.type_() == mime::TEXT && mime.subtype() == mime::PLAIN
///                        })
///                        .error_handler(json_error_handler)  // Use our custom error response
///             }))
///             .route(web::post().to(index))