diff --git a/Cargo.lock b/Cargo.lock index 4ea5bdd7..64d52171 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5806,9 +5806,8 @@ dependencies = [ name = "template-tinytemplate" 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", "serde_json", "tinytemplate", ] diff --git a/template_engines/tinytemplate/Cargo.toml b/template_engines/tinytemplate/Cargo.toml index 15115779..d2f79730 100644 --- a/template_engines/tinytemplate/Cargo.toml +++ b/template_engines/tinytemplate/Cargo.toml @@ -4,8 +4,7 @@ version = "1.0.0" edition = "2021" [dependencies] -env_logger = "0.8" +env_logger = "0.9.0" tinytemplate = "1.1" -actix-http = "2" -actix-web = "3" +actix-web = "4.0.0-beta.21" serde_json = "1" diff --git a/template_engines/tinytemplate/src/main.rs b/template_engines/tinytemplate/src/main.rs index 1e3cf46f..67d4119f 100644 --- a/template_engines/tinytemplate/src/main.rs +++ b/template_engines/tinytemplate/src/main.rs @@ -1,9 +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 serde_json::json; use tinytemplate::TinyTemplate; @@ -40,7 +41,7 @@ async fn main() -> std::io::Result<()> { tt.add_template("error.html", ERROR).unwrap(); App::new() - .data(tt) + .app_data(web::Data::new(tt)) .wrap(middleware::Logger::default()) // enable logger .service(web::resource("/").route(web::get().to(index))) .service(web::scope("").wrap(error_handlers())) @@ -51,27 +52,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