Skip to main content

Module json_body

Module json_body 

Source
Expand description

JSON body extractor with consistent error responses.

JsonBody<T> wraps Axum’s Json<T> extractor and converts parse failures into the standard Aro JSON error envelope format, rather than Axum’s default plain-text error responses.

§Example

use aro_web::json_body::JsonBody;

#[aro::post("/users")]
async fn create_user(JsonBody(payload): JsonBody<CreateUser>) -> Json<User> {
    // payload is already deserialized; parse errors returned as JSON
    Json(User { name: payload.name })
}

Structs§

JsonBody
A JSON body extractor that produces Aro-consistent error responses.

Enums§

JsonBodyRejection
Rejection type for JsonBody extraction failures.