pub struct IntoResponseFailed;Expand description
Response part that stops status code overrides.
This type should be used by types implementing IntoResponseParts or
IntoResponse when they fail to produce the response usually expected of
them and return some sort of error response instead.
It is checked used by the tuple impls of IntoResponse that have a
[StatusCode] as their first element to ignore that status code.
Consider the following example:
fn my_handler(/* ... */) -> (StatusCode, Json<CreatedResponse>) {
// This response type's serialization may fail
let response = CreatedResponse { /* ... */ };
(StatusCode::CREATED, Json(response))
}When response serialization succeeds, the server responds with a status
code of 201 Created (overwriting Jsons default status code of 200 OK),
and the expected JSON payload.
When response serialization fails hoewever, impl IntoResponse for Json
return a response with status code 500 Internal Server Error, and
IntoResponseFailed as a response extension, and the 201 Created override
is ignored.
This is a behavior introduced with axum 0.9.
To force a status code override even when an inner IntoResponseParts /
IntoResponse failed, use ForceStatusCode.
Trait Implementations§
Source§impl Clone for IntoResponseFailed
impl Clone for IntoResponseFailed
Source§fn clone(&self) -> IntoResponseFailed
fn clone(&self) -> IntoResponseFailed
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more