From c1c24146266a1e35748421c1afba10b24794af26 Mon Sep 17 00:00:00 2001 From: Joris Date: Sat, 8 Jun 2024 12:09:01 +0200 Subject: Add content type text/html --- src/routes.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/routes.rs b/src/routes.rs index b54e565..fed3067 100644 --- a/src/routes.rs +++ b/src/routes.rs @@ -27,7 +27,12 @@ pub async fn routes( let files_dir = Path::new(&files_dir); match (request.method(), path) { - (&Method::GET, [""]) => Ok(response(StatusCode::OK, templates::INDEX.to_string())), + (&Method::GET, [""]) => { + Ok(with_headers( + response(StatusCode::OK, templates::INDEX.to_string()), + vec![(CONTENT_TYPE, "text/html")], + )) + }, (&Method::GET, ["static", "main.js"]) => Ok(static_file( include_str!("static/main.js").to_string(), "application/javascript", @@ -126,7 +131,10 @@ async fn get( let file = db::get_file(&db_conn, file_id.to_string()).await; match (get_file, file) { (GetFile::ShowPage, Ok(Some(file))) => { - Ok(response(StatusCode::OK, templates::file_page(file))) + Ok(with_headers( + response(StatusCode::OK, templates::file_page(file)), + vec![(CONTENT_TYPE, "text/html")], + )) } (GetFile::Download, Ok(Some(file))) => { let path = files_dir.join(file_id); -- cgit v1.2.3