Add Last Modified Header to npdi
All checks were successful
Build and Test / rust-boss (push) Successful in 7m15s

This commit is contained in:
BloxerHD 2026-06-30 23:41:51 +01:00
commit af5af13c2a
Signed by: bloxerhd018
SSH key fingerprint: SHA256:ItSfcfhpXlfkMK3uQSDYW5X3XKm0hbHWQqWcCK57px8

View file

@ -1,4 +1,5 @@
use std::io::Cursor; use std::io::Cursor;
use chrono::{DateTime, NaiveDateTime, Utc};
use rocket::http::{Header, Status}; use rocket::http::{Header, Status};
use rocket::{Data, State}; use rocket::{Data, State};
use rocket::response::{Response, Responder}; use rocket::response::{Response, Responder};
@ -14,16 +15,20 @@ pub struct DataResponder<T> {
content_disposition_header: Header<'static>, content_disposition_header: Header<'static>,
content_transfer_encoding_header: Header<'static>, content_transfer_encoding_header: Header<'static>,
content_length_header: Header<'static>, content_length_header: Header<'static>,
last_modified_header: Header<'static>,
} }
impl<'r, 'o: 'r, T: Responder<'r, 'o>> DataResponder<T> { impl<'r, 'o: 'r, T: Responder<'r, 'o>> DataResponder<T> {
fn new(inner: T, content_length: String) -> Self { fn new(inner: T, content_length: String, updated: NaiveDateTime) -> Self {
let updated_utc: DateTime<Utc> = DateTime::from_naive_utc_and_offset(updated, Utc);
DataResponder { DataResponder {
inner, inner,
content_type_header: Header::new("Content-Type", "applicatoin/octet-stream"), // Intentional spelling mistake content_type_header: Header::new("Content-Type", "applicatoin/octet-stream"), // Intentional spelling mistake
content_disposition_header: Header::new("Content-Disposition", "attachment"), content_disposition_header: Header::new("Content-Disposition", "attachment"),
content_transfer_encoding_header: Header::new("Content-Transfer-Encoding", "binary"), content_transfer_encoding_header: Header::new("Content-Transfer-Encoding", "binary"),
content_length_header: Header::new("Content-Length", content_length), content_length_header: Header::new("Content-Length", content_length),
last_modified_header: Header::new("Last-Modified", updated_utc.format("%a, %d %b %Y %H:%M:%S GMT").to_string()),
} }
} }
} }
@ -61,5 +66,5 @@ pub async fn data(pool: &State<Pool>, s3: &State<S3Client>,boss_app_id: String,
.into_bytes() .into_bytes()
.to_vec(); .to_vec();
Ok(DataResponder::new(data, file_wup.size.to_string())) Ok(DataResponder::new(data, file_wup.size.to_string(), file_wup.updated))
} }