standard_error/extras/response.rs
1use crate::StandardError;
2use axum::response::{Response, IntoResponse, Html};
3use axum::Json;
4use serde_json::json;
5
6impl IntoResponse for StandardError {
7 fn into_response(self) -> Response {
8 #[cfg(feature = "askama")]
9 if let Some(html) = self.html {
10 return (self.status_code, Html(html)).into_response();
11 }
12 (self.status_code, Json(json!({"detail": self.message}))).into_response()
13 }
14}