feat(middleware): add middleware to attach default response headers (#824)

This commit is contained in:
Sanchith Hegde
2023-04-04 11:26:05 +05:30
committed by GitHub
parent 35d3e27724
commit 6d7b11a0f0
9 changed files with 23 additions and 49 deletions

View File

@ -153,14 +153,8 @@ impl From<ConfigError> for ApplicationError {
}
fn error_response<T: Display>(err: &T) -> actix_web::HttpResponse {
use actix_web::http::header;
use crate::consts;
actix_web::HttpResponse::BadRequest()
.append_header((header::STRICT_TRANSPORT_SECURITY, consts::HSTS_HEADER_VALUE))
.append_header((header::VIA, "Juspay_Router"))
.content_type("application/json")
.content_type(mime::APPLICATION_JSON)
.body(format!(r#"{{ "error": {{ "message": "{err}" }} }}"#))
}