From e0ee90d6c6a14634aed56f56f7f4f7d4a37224df Mon Sep 17 00:00:00 2001 From: Vri Date: Wed, 11 Oct 2023 21:27:09 +0200 Subject: [PATCH] add fn header --- src/main.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index 522796a..3b5e160 100644 --- a/src/main.rs +++ b/src/main.rs @@ -25,10 +25,7 @@ async fn index() -> impl IntoResponse { // Render the template with the given context let rendered = tera.render("index.html.tera", &context).unwrap(); - ( - [(header::CONTENT_TYPE, "text/html; charset=utf-8")], - rendered, - ) + header(rendered) } async fn search(Query(params): Query>) -> impl IntoResponse { @@ -39,8 +36,12 @@ async fn search(Query(params): Query>) -> impl IntoRespo let rendered = tera.render("search.html.tera", &context).unwrap(); + header(rendered) +} + +fn header(rendered: impl ToString) -> impl IntoResponse { ( [(header::CONTENT_TYPE, "text/html; charset=utf-8")], - rendered, + rendered.to_string(), ) }