diff --git a/src/main.rs b/src/main.rs index 2acb8e5..d1490ce 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,7 +10,7 @@ use tera::Tera; #[tokio::main] async fn main() { - // build our application with a single route + // application routes let app = Router::new() .route("/", get(index)) .route("/search", get(search)) @@ -24,12 +24,8 @@ async fn main() { } async fn index() -> impl IntoResponse { - // Create a new Tera instance and add a template from a string let tera = tera_create(); - // Prepare the context with some data let context = tera::Context::new(); - - // Render the template with the given context let rendered = tera.render("index.html", &context).unwrap(); header(rendered) @@ -37,12 +33,11 @@ async fn index() -> impl IntoResponse { async fn search(Query(params): Query>) -> impl IntoResponse { let tera = tera_create(); - // Prepare the context with some data let mut context = tera::Context::new(); - context.insert("query", params.get("q").unwrap()); - let rendered = tera.render("search.html", &context).unwrap(); + context.insert("query", params.get("q").unwrap()); + header(rendered) }