From: Ian Jackson Date: Wed, 30 Mar 2022 20:39:11 +0000 (+0100) Subject: actix files content-type fixup: wip, call fn middlware X-Git-Tag: otter-1.0.0~78 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=438f03bd213e71d5743613051472ed3b54e0ecf2;p=otter.git actix files content-type fixup: wip, call fn middlware Signed-off-by: Ian Jackson --- diff --git a/daemon/main.rs b/daemon/main.rs index 0707e320..70b6ff1b 100644 --- a/daemon/main.rs +++ b/daemon/main.rs @@ -29,7 +29,7 @@ use actix_web::{route, post, HttpServer, Responder}; use actix_web::{HttpResponse, HttpResponseBuilder, ResponseError}; use actix_web::{HttpRequest, FromRequest}; use actix_web::services; -use actix_web::dev::HttpServiceFactory; +use actix_web::dev::{HttpServiceFactory, Service as _, ServiceResponse}; use actix_web::web::{self, Bytes, Data, Json, Path, Query}; use actix_web::body::BoxBody; use actix_web::http::header; @@ -374,6 +374,11 @@ async fn r_bundle(path: Path<( .set_content_type(ctype.into_mime()) } +#[throws(actix_web::Error)] +fn src_ct_fixup(resp: ServiceResponse) -> ServiceResponse { + resp +} + /* #[derive(Debug,Copy,Clone)] struct ContentTypeFixup; @@ -523,6 +528,9 @@ async fn main() -> Result<(),StartupError> { .add((header::X_FRAME_OPTIONS, "DENY")) .add((header::REFERRER_POLICY, "no-referrer")) ) + .wrap_fn(|req, svc| { + svc.call(req).map(|resp| resp.and_then(src_ct_fixup)) + }) .wrap(middleware::Logger::default()) ;