mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-30 01:27:31 +08:00
feat(middleware): add middleware to attach default response headers (#824)
This commit is contained in:
@ -51,18 +51,14 @@ pub mod error_parser {
|
||||
|
||||
impl ResponseError for CustomJsonError {
|
||||
fn status_code(&self) -> StatusCode {
|
||||
StatusCode::INTERNAL_SERVER_ERROR
|
||||
StatusCode::BAD_REQUEST
|
||||
}
|
||||
|
||||
fn error_response(&self) -> actix_web::HttpResponse<actix_web::body::BoxBody> {
|
||||
use actix_web::http::header;
|
||||
|
||||
use crate::consts;
|
||||
|
||||
actix_web::HttpResponseBuilder::new(StatusCode::BAD_REQUEST)
|
||||
actix_web::HttpResponseBuilder::new(self.status_code())
|
||||
.insert_header((header::CONTENT_TYPE, mime::APPLICATION_JSON))
|
||||
.insert_header((header::STRICT_TRANSPORT_SECURITY, consts::HSTS_HEADER_VALUE))
|
||||
.insert_header((header::VIA, "Juspay_Router"))
|
||||
.body(self.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user