Expand description
Poem response types for ProblemDetails. Requires feature poem.
With the poem feature enabled, ProblemDetails implements IntoResponse using
JsonProblemDetails. You can also return JsonProblemDetails to be specific.
If you want to return XML, you can use XmlProblemDetails (requires feature xml).
ยงExample
use poem::{get, Route};
use http::StatusCode;
use problem_details::ProblemDetails;
#[poem::handler]
async fn handler() -> Result<&'static str, ProblemDetails> {
// always return a problem description
Err(ProblemDetails::from_status_code(StatusCode::IM_A_TEAPOT)
.with_detail("short and stout"))
}
fn main() {
let app = Route::new().at("/", get(handler));
// build and run server...
}