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

@ -3,7 +3,6 @@ use actix_web::{
middleware::{Compress, Logger},
web, App, HttpServer, Responder,
};
use actix_web_lab::respond::Html;
use sailfish::TemplateOnce;
#[derive(TemplateOnce)]
@ -24,7 +23,7 @@ async fn greet(params: web::Path<(String,)>) -> actix_web::Result<impl Responder
.render_once()
.map_err(error::ErrorInternalServerError)?;
Ok(Html(body))
Ok(web::Html::new(body))
}
#[get("/page-{id:\\d+}")]
@ -33,12 +32,12 @@ async fn page(params: web::Path<(i32,)>) -> actix_web::Result<impl Responder> {
.render_once()
.map_err(error::ErrorInternalServerError)?;
Ok(Html(body))
Ok(web::Html::new(body))
}
#[get("/")]
async fn hello() -> impl Responder {
Html("<p>Hello world!</p>".to_owned())
web::Html::new("<p>Hello world!</p>".to_owned())
}
#[actix_web::main]