Skip to content

Commit

Permalink
fix: エラーメッセージでjsonを返すように
Browse files Browse the repository at this point in the history
  • Loading branch information
rito528 committed Mar 27, 2024
1 parent 2c80ead commit 0d8f248
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
5 changes: 3 additions & 2 deletions server/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ tracing-subscriber = { version = "0.3.18", features = ["std", "registry", "env-f
tower = "0.4.13"
envy = "0.4.2"
once_cell = "1.19.0"
serde_json = "1.0.115"
6 changes: 4 additions & 2 deletions server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ mod presentation {
use axum::extract::State;
use axum::http::StatusCode;
use axum::response::{ErrorResponse, IntoResponse, Response, Result};
use axum::Json;
use serde_json::json;
use tokio_util::io::ReaderStream;

#[tracing::instrument]
Expand All @@ -151,7 +153,7 @@ mod presentation {
Err(_) => Err(ErrorResponse::from(
(
StatusCode::SERVICE_UNAVAILABLE,
"SeichiAssist was not built yet.",
Json(json!({"error": "SeichiAssist was not built yet."})),
)
.into_response(),
)),
Expand All @@ -177,7 +179,7 @@ mod presentation {
Err(_) => Err(ErrorResponse::from(
(
StatusCode::SERVICE_UNAVAILABLE,
"SeichiAssist was not built yet.",
Json(json!({"error": "SeichiAssist was not built yet."})),
)
.into_response(),
)),
Expand Down

0 comments on commit 0d8f248

Please sign in to comment.