pub struct Problem {
pub problem_type: Option<String>,
pub title: String,
pub status: u16,
pub detail: Option<String>,
pub instance: Option<String>,
}Expand description
An RFC 9457 problem details response.
Serializes to application/problem+json with the correct HTTP status code.
§Manual construction
use axum_problem::Problem;
let p = Problem::new(404)
.title("Order Not Found")
.detail("Order 1001 does not exist");Fields§
§problem_type: Option<String>URI reference identifying the problem type. Defaults to "about:blank".
title: StringShort human-readable summary of the problem type.
status: u16HTTP status code.
detail: Option<String>Human-readable explanation specific to this occurrence.
instance: Option<String>URI identifying the specific occurrence of this problem.
Implementations§
Source§impl Problem
impl Problem
Sourcepub fn new(status: u16) -> Self
pub fn new(status: u16) -> Self
Create a new problem for the given HTTP status code. The title is set automatically from the status code.
Sourcepub fn problem_type(self, t: impl Into<String>) -> Self
pub fn problem_type(self, t: impl Into<String>) -> Self
Set the problem type URI (defaults to "about:blank" in the response).
Sourcepub fn detail(self, detail: impl Into<String>) -> Self
pub fn detail(self, detail: impl Into<String>) -> Self
Add a human-readable explanation for this specific occurrence.
Sourcepub fn instance(self, instance: impl Into<String>) -> Self
pub fn instance(self, instance: impl Into<String>) -> Self
Add a URI identifying this specific occurrence.
pub fn bad_request() -> Self
pub fn forbidden() -> Self
pub fn not_found() -> Self
pub fn method_not_allowed() -> Self
pub fn conflict() -> Self
pub fn unprocessable_entity() -> Self
pub fn too_many_requests() -> Self
pub fn internal_server_error() -> Self
pub fn not_implemented() -> Self
Trait Implementations§
Source§impl IntoResponse for Problem
impl IntoResponse for Problem
Source§fn into_response(self) -> Response
fn into_response(self) -> Response
Create a response.
Auto Trait Implementations§
impl Freeze for Problem
impl RefUnwindSafe for Problem
impl Send for Problem
impl Sync for Problem
impl Unpin for Problem
impl UnsafeUnpin for Problem
impl UnwindSafe for Problem
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, S> Handler<IntoResponseHandler, S> for T
impl<T, S> Handler<IntoResponseHandler, S> for T
Source§fn call(
self,
_req: Request<Body>,
_state: S,
) -> <T as Handler<IntoResponseHandler, S>>::Future
fn call( self, _req: Request<Body>, _state: S, ) -> <T as Handler<IntoResponseHandler, S>>::Future
Call the handler with the given request.
Source§fn layer<L>(self, layer: L) -> Layered<L, Self, T, S>where
L: Layer<HandlerService<Self, T, S>> + Clone,
<L as Layer<HandlerService<Self, T, S>>>::Service: Service<Request<Body>>,
fn layer<L>(self, layer: L) -> Layered<L, Self, T, S>where
L: Layer<HandlerService<Self, T, S>> + Clone,
<L as Layer<HandlerService<Self, T, S>>>::Service: Service<Request<Body>>,
Apply a
tower::Layer to the handler. Read moreSource§fn with_state(self, state: S) -> HandlerService<Self, T, S>
fn with_state(self, state: S) -> HandlerService<Self, T, S>
Convert the handler into a
Service by providing the stateSource§impl<H, T> HandlerWithoutStateExt<T> for H
impl<H, T> HandlerWithoutStateExt<T> for H
Source§fn into_service(self) -> HandlerService<H, T, ()>
fn into_service(self) -> HandlerService<H, T, ()>
Convert the handler into a
Service and no state.Source§fn into_make_service(self) -> IntoMakeService<HandlerService<H, T, ()>>
fn into_make_service(self) -> IntoMakeService<HandlerService<H, T, ()>>
Convert the handler into a
MakeService and no state. Read more