add fn header

This commit is contained in:
Vri 🌈 2023-10-11 21:27:09 +02:00
parent 23cb696f61
commit e0ee90d6c6
Signed by: vrifox
SSH key fingerprint: SHA256:7OLOvW+jmULkXpdl5rUWgid7WJQhOIEgj+4WP/PtCpI

View file

@ -25,10 +25,7 @@ async fn index() -> impl IntoResponse {
// Render the template with the given context // Render the template with the given context
let rendered = tera.render("index.html.tera", &context).unwrap(); let rendered = tera.render("index.html.tera", &context).unwrap();
( header(rendered)
[(header::CONTENT_TYPE, "text/html; charset=utf-8")],
rendered,
)
} }
async fn search(Query(params): Query<HashMap<String, String>>) -> impl IntoResponse { async fn search(Query(params): Query<HashMap<String, String>>) -> impl IntoResponse {
@ -39,8 +36,12 @@ async fn search(Query(params): Query<HashMap<String, String>>) -> impl IntoRespo
let rendered = tera.render("search.html.tera", &context).unwrap(); 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")], [(header::CONTENT_TYPE, "text/html; charset=utf-8")],
rendered, rendered.to_string(),
) )
} }