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

standardize examples

This commit is contained in:
Rob Ede
2023-03-14 03:11:49 +00:00
parent ca6eaee52e
commit 6424e4e023
30 changed files with 169 additions and 395 deletions

View File

@ -8,4 +8,5 @@ actix-web.workspace = true
actix-web-lab.workspace = true
env_logger.workspace = true
tera = "1.8.0"
log.workspace = true
tera = "1.8"

View File

@ -33,16 +33,16 @@ async fn index(
#[actix_web::main]
async fn main() -> std::io::Result<()> {
std::env::set_var("RUST_LOG", "actix_web=info");
env_logger::init();
env_logger::init_from_env(env_logger::Env::new().default_filter_or("info"));
log::info!("starting HTTP server at http://localhost:8080");
println!("Listening on: 127.0.0.1:8080, open browser and visit have a try!");
HttpServer::new(|| {
let tera = Tera::new(concat!(env!("CARGO_MANIFEST_DIR"), "/templates/**/*")).unwrap();
App::new()
.app_data(web::Data::new(tera))
.wrap(middleware::Logger::default()) // enable logger
.wrap(middleware::Logger::default())
.service(web::resource("/").route(web::get().to(index)))
.service(web::scope("").wrap(error_handlers()))
})