set error content type to json

This commit is contained in:
marin postma 2021-06-21 18:48:05 +02:00
parent 1e4592dd7e
commit f91a3bc6ab
No known key found for this signature in database
GPG Key ID: 6088B7721C3E39F9
1 changed files with 3 additions and 1 deletions

View File

@ -60,7 +60,9 @@ where T: ErrorCode
impl aweb::error::ResponseError for ResponseError {
fn error_response(&self) -> aweb::BaseHttpResponse<Body> {
let json = serde_json::to_vec(self).unwrap();
BaseHttpResponseBuilder::new(self.status_code()).body(json)
BaseHttpResponseBuilder::new(self.status_code())
.content_type("application/json")
.body(json)
}
fn status_code(&self) -> StatusCode {