1
0
mirror of https://github.com/actix/examples synced 2024-11-23 22:41:07 +01:00

add logger for askama template example (#466)

This commit is contained in:
shiomiyan 2021-11-29 23:46:19 +09:00 committed by GitHub
parent e0e1c9b31f
commit ba5ab96897
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View File

@ -5,6 +5,7 @@ authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
edition = "2018"
[dependencies]
env_logger = "0.8"
actix-web = "3"
askama = "0.9"

View File

@ -1,6 +1,6 @@
use std::collections::HashMap;
use actix_web::{web, App, HttpResponse, HttpServer, Result};
use actix_web::{middleware, web, App, HttpResponse, HttpServer, Result};
use askama::Template;
#[derive(Template)]
@ -30,9 +30,14 @@ async fn index(query: web::Query<HashMap<String, String>>) -> Result<HttpRespons
#[actix_web::main]
async fn main() -> std::io::Result<()> {
std::env::set_var("RUST_LOG", "actix_web=info");
env_logger::init();
// start http server
HttpServer::new(move || {
App::new().service(web::resource("/").route(web::get().to(index)))
App::new()
.wrap(middleware::Logger::default())
.service(web::resource("/").route(web::get().to(index)))
})
.bind("127.0.0.1:8080")?
.run()