feat: Add HSTS headers to response (#725)

This commit is contained in:
Kartikeya Hegde
2023-03-10 14:49:58 +05:30
committed by GitHub
parent c085e460be
commit 7ed665ecec
7 changed files with 34 additions and 13 deletions

View File

@ -153,8 +153,13 @@ 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(("Via", "Juspay_Router"))
.append_header((header::STRICT_TRANSPORT_SECURITY, consts::HSTS_HEADER_VALUE))
.append_header((header::VIA, "Juspay_Router"))
.content_type("application/json")
.body(format!(r#"{{ "error": {{ "message": "{err}" }} }}"#))
}