-
According to RFC 9110:
and Section 5.6.7 is
actix-web cant be 100% sure that the time it sees (e.g. use of std::time is using NTP or similar, but it is highly likely, especially given that actix cant build without Given this is a MUST, IMO it would be great for actix-web to provide an easy way to comply with the spec. Using /// Middleware to add Date header to all responses.
/// Usage: `App::new().wrap(map_response(add_date_header))`
async fn add_date_header(
mut res: actix_web::dev::ServiceResponse<impl actix_web::body::MessageBody>,
) -> actix_web::Result<actix_web::dev::ServiceResponse<impl actix_web::body::MessageBody>> {
res.headers_mut().insert(
actix_web::http::header::DATE,
actix_web::http::header::HttpDate::from(std::time::SystemTime::now()).try_into_value()?,
);
Ok(res)
} |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Great news, Actix Web already does this automatically!
|
Beta Was this translation helpful? Give feedback.
Great news, Actix Web already does this automatically!