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

refactor: use graduated Html responder

This commit is contained in:
Rob Ede
2024-07-07 00:23:03 +01:00
parent 10aff3cdb1
commit a67c7803e6
13 changed files with 27 additions and 40 deletions

View File

@ -8,7 +8,7 @@ use actix_web::{
middleware::{ErrorHandlerResponse, ErrorHandlers},
web, App, HttpResponse, HttpServer, Responder, Result,
};
use actix_web_lab::{extract::Path, respond::Html};
use actix_web_lab::extract::Path;
use fluent_templates::{static_loader, FluentLoader, Loader as _};
use handlebars::{DirectorySourceOptions, Handlebars};
use serde_json::json;
@ -31,7 +31,7 @@ static_loader! {
async fn index(hb: web::Data<Handlebars<'_>>, lang: LangChoice) -> impl Responder {
let data = json!({ "lang": lang });
let body = hb.render("index", &data).unwrap();
Html(body)
web::Html::new(body)
}
#[get("/{user}/{data}")]
@ -46,7 +46,7 @@ async fn user(
"data": info.1
});
let body = hb.render("user", &data).unwrap();
Html(body)
web::Html::new(body)
}
#[actix_web::main]