diff --git a/http/src/response.rs b/http/src/response.rs index a66fec9c..1b2bbc52 100644 --- a/http/src/response.rs +++ b/http/src/response.rs @@ -23,7 +23,7 @@ impl Response { pub fn ok>(response: T) -> Self { Response { code: StatusCode::OK, - content_type: HeaderValue::from_static("application/json; charset=utf-8"), + content_type: application_json(), content: response.into(), } } @@ -41,7 +41,7 @@ impl Response { pub fn service_unavailable>(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(), } } @@ -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 for hyper::Response { /// Converts from a jsonrpc `Response` to a `hyper::Response`