MCPcopy Create free account
hub / github.com/actix/examples / main

Function main

templating/tera/src/main.rs:35–52  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

33
34#[actix_web::main]
35async fn main() -> std::io::Result<()> {
36 env_logger::init_from_env(env_logger::Env::new().default_filter_or("info"));
37
38 log::info!("starting HTTP server at http://localhost:8080");
39
40 HttpServer::new(|| {
41 let tera = Tera::new(concat!(env!("CARGO_MANIFEST_DIR"), "/templates/**/*")).unwrap();
42
43 App::new()
44 .app_data(web::Data::new(tera))
45 .wrap(middleware::Logger::default())
46 .service(web::resource("/").route(web::get().to(index)))
47 .service(web::scope("").wrap(error_handlers()))
48 })
49 .bind(("127.0.0.1", 8080))?
50 .run()
51 .await
52}
53
54// Custom error handlers, to return HTML responses when an error occurs.
55fn error_handlers() -> ErrorHandlers<BoxBody> {

Callers

nothing calls this directly

Calls 2

runMethod · 0.80
error_handlersFunction · 0.70

Tested by

no test coverage detected