Skip to content

Commit 8260ce5

Browse files
committed
errors: Implement IntoResponse for RouteBlocked
1 parent bbcc099 commit 8260ce5

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/util/errors/json.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use axum::response::{IntoResponse, Response};
2+
use axum::Json;
13
use std::fmt;
24

35
use super::{AppError, InternalAppErrorStatic};
@@ -286,3 +288,10 @@ impl fmt::Display for RouteBlocked {
286288
f.write_str("This route is temporarily blocked. See https://status.crates.io.")
287289
}
288290
}
291+
292+
impl IntoResponse for RouteBlocked {
293+
fn into_response(self) -> Response {
294+
let body = Json(json!({ "errors": [{ "detail": self.to_string() }] }));
295+
(StatusCode::SERVICE_UNAVAILABLE, body).into_response()
296+
}
297+
}

0 commit comments

Comments
 (0)