diff --git a/Cargo.lock b/Cargo.lock index 40b07b8e..4ea5bdd7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5797,9 +5797,8 @@ dependencies = [ name = "template-tera" version = "1.0.0" dependencies = [ - "actix-http 2.2.2", - "actix-web 3.3.3", - "env_logger 0.8.4", + "actix-web 4.0.0-beta.21", + "env_logger 0.9.0", "tera", ] diff --git a/template_engines/tera/Cargo.toml b/template_engines/tera/Cargo.toml index cf12433c..e79f2073 100644 --- a/template_engines/tera/Cargo.toml +++ b/template_engines/tera/Cargo.toml @@ -4,7 +4,6 @@ version = "1.0.0" edition = "2021" [dependencies] -env_logger = "0.8" +env_logger = "0.9.0" tera = "1.8.0" -actix-http = "2" -actix-web = "3" +actix-web = "4.0.0-beta.21" diff --git a/template_engines/tera/src/main.rs b/template_engines/tera/src/main.rs index 14f2bfa6..55e9eea0 100644 --- a/template_engines/tera/src/main.rs +++ b/template_engines/tera/src/main.rs @@ -1,10 +1,10 @@ -use std::collections::HashMap; - -use actix_http::{body::Body, Response}; +use actix_web::body::BoxBody; use actix_web::dev::ServiceResponse; +use actix_web::http::header::ContentType; use actix_web::http::StatusCode; -use actix_web::middleware::errhandlers::{ErrorHandlerResponse, ErrorHandlers}; +use actix_web::middleware::{ErrorHandlerResponse, ErrorHandlers}; use actix_web::{error, middleware, web, App, Error, HttpResponse, HttpServer, Result}; +use std::collections::HashMap; use tera::Tera; // store tera template in application state @@ -37,7 +37,7 @@ async fn main() -> std::io::Result<()> { Tera::new(concat!(env!("CARGO_MANIFEST_DIR"), "/templates/**/*")).unwrap(); App::new() - .data(tera) + .app_data(web::Data::new(tera)) .wrap(middleware::Logger::default()) // enable logger .service(web::resource("/").route(web::get().to(index))) .service(web::scope("").wrap(error_handlers())) @@ -48,27 +48,28 @@ async fn main() -> std::io::Result<()> { } // Custom error handlers, to return HTML responses when an error occurs. -fn error_handlers() -> ErrorHandlers
{ +fn error_handlers() -> ErrorHandlers