pub type PayloadJson<T> = Result<Json<T>, JsonRejection>;
Expand description
This type is used when you have a JSON request body as it can potentially throw
[JsonRejection
], which is not handled by serde_json
.
See this example when using in a handler:
async fn update_user_base(payload: PayloadJson<UserUpdate>) -> Result<Json<UserUpdate>> {
Json(user) = payload?;
println!("User ID: {user.id}");
}
Aliased Type§
enum PayloadJson<T> {
Ok(Json<T>),
Err(JsonRejection),
}