Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[suggestion] added plain text format#4218 #4236

Closed
wants to merge 7 commits into from
Closed
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions torii/src/routing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ enum Health {
Healthy,
}

pub fn handle_health() -> Json {
reply::json(&Health::Healthy)
pub fn handle_health() -> impl warp::Reply {
warp::reply::with_status("Healthy", StatusCode::OK).header("Content-Type", "text/plain")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Returning a &'static str will be more terse and will still correctly set the Content-Type header: https://docs.rs/warp/latest/src/warp/reply.rs.html#436-443

}

#[iroha_futures::telemetry_future]
Expand Down Expand Up @@ -305,15 +305,15 @@ pub mod subscription {

#[iroha_futures::telemetry_future]
#[cfg(feature = "telemetry")]
pub async fn handle_version(sumeragi: SumeragiHandle) -> Json {
pub async fn handle_version(sumeragi: SumeragiHandle) -> impl warp::Reply {
use iroha_version::Version;

let string = sumeragi
.apply_wsv(WorldStateView::latest_block_ref)
.expect("Genesis not applied. Nothing we can do. Solve the issue and rerun.")
.version()
.to_string();
reply::json(&string)
warp::reply::with_status(string, warp::http::StatusCode::OK).header("Content-Type", "text/plain")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same, but can return the version String directly

}

#[cfg(feature = "telemetry")]
Expand Down
Loading