Skip to content
Open
Changes from all 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: 6 additions & 2 deletions http/src/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ impl Response {
pub fn ok<T: Into<String>>(response: T) -> Self {
Response {
code: StatusCode::OK,
content_type: HeaderValue::from_static("application/json; charset=utf-8"),
content_type: application_json(),
content: response.into(),
}
}
Expand All @@ -41,7 +41,7 @@ impl Response {
pub fn service_unavailable<T: Into<String>>(msg: T) -> Self {
Response {
code: StatusCode::SERVICE_UNAVAILABLE,
content_type: HeaderValue::from_static("application/json; charset=utf-8"),
content_type: application_json(),
content: msg.into(),
}
}
Expand Down Expand Up @@ -123,6 +123,10 @@ fn plain_text() -> HeaderValue {
HeaderValue::from_static("text/plain; charset=utf-8")
}

fn application_json() -> HeaderValue {
HeaderValue::from_static("application/json; charset=utf-8")
}

// TODO: Consider switching to a `TryFrom` conversion once it stabilizes.
impl From<Response> for hyper::Response<Body> {
/// Converts from a jsonrpc `Response` to a `hyper::Response`
Expand Down