#[macro_use] extern crate log; use actix_web::middleware::Logger; use actix_web::{web, App, HttpResponse, HttpServer, Responder}; async fn index() -> impl Responder { HttpResponse::Ok().body("Hello world!") } fn config(cfg: &mut web::ServiceConfig) { cfg.service( web::resource("/") .route(web::get().to(index)) .route(web::head().to(|| HttpResponse::MethodNotAllowed())), ); } #[actix_web::main] async fn main() -> std::io::Result<()> { env_logger::init_from_env(env_logger::Env::new().default_filter_or("info")); HttpServer::new(|| App::new().wrap(Logger::default()).configure(config)) .bind("127.0.0.1:8000")? .workers(4) .run() .await }