From d69f7fc08c491817358d944ab8177152d3afea19 Mon Sep 17 00:00:00 2001 From: alyx Date: Wed, 3 Apr 2024 11:49:07 -0400 Subject: Use http::Response for constructing replies --- src/main.rs | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/main.rs b/src/main.rs index 6669791..e3ac9eb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -51,20 +51,23 @@ async fn main() { let (theme, res) = lfm_embed::theming::render_theme(q.theme.as_deref(), &data); log::debug!(target: "lfm_embed::server::user", "Using theme {theme}"); + match res { Err(status) => - Box::new(warp::reply::with_status(warp::reply::html("

Internal Server Error.

"), status)) - as Box, + http::Response::builder() + .status(status) + .header("Content-Type", "text/html") + .body("

Internal Server Error.

Occurred when templating, check the logs.

".into()) + .unwrap(), + Ok(contents) => - Box::new(warp::reply::with_header( - warp::reply::with_header( - warp::reply::with_status( - warp::reply::html( - contents - ), status - ), "Refresh", dur.as_secs() - ), "X-Selected-Theme", theme - )) as Box + http::Response::builder() + .status(status) + .header("Refresh", dur.as_secs()) + .header("X-Selected-Theme", theme) + .header("Content-Type", "text/html") + .body(contents) + .unwrap() } }); -- cgit v1.2.3-70-g09d2