1
0
mirror of https://github.com/actix/examples synced 2025-06-26 17:17:42 +02:00

reduce minijinja boilerplate

This commit is contained in:
Rob Ede
2022-10-16 21:36:23 +01:00
parent 8a22559cac
commit bf0386ade7
5 changed files with 62 additions and 35 deletions

View File

@ -6,7 +6,7 @@ use actix_web::{
error,
http::{header::ContentType, StatusCode},
middleware::{self, ErrorHandlerResponse, ErrorHandlers},
web, App, Error, HttpResponse, HttpServer, Result,
web, App, Error, HttpResponse, HttpServer, Responder, Result,
};
use actix_web_lab::respond::Html;
use tera::Tera;
@ -15,7 +15,7 @@ use tera::Tera;
async fn index(
tmpl: web::Data<tera::Tera>,
query: web::Query<HashMap<String, String>>,
) -> Result<HttpResponse, Error> {
) -> Result<impl Responder, Error> {
let s = if let Some(name) = query.get("name") {
// submitted form
let mut ctx = tera::Context::new();