add fn header
This commit is contained in:
parent
23cb696f61
commit
e0ee90d6c6
1 changed files with 6 additions and 5 deletions
11
src/main.rs
11
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<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();
|
||||
|
||||
header(rendered)
|
||||
}
|
||||
|
||||
fn header(rendered: impl ToString) -> impl IntoResponse {
|
||||
(
|
||||
[(header::CONTENT_TYPE, "text/html; charset=utf-8")],
|
||||
rendered,
|
||||
rendered.to_string(),
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue