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

Function main

databases/sqlite/src/main.rs:51–73  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

49
50#[actix_web::main]
51async fn main() -> io::Result<()> {
52 env_logger::init_from_env(env_logger::Env::new().default_filter_or("info"));
53
54 // connect to SQLite DB
55 let manager = SqliteConnectionManager::file("weather.db");
56 let pool = Pool::new(manager).unwrap();
57
58 log::info!("starting HTTP server at http://localhost:8080");
59
60 // start HTTP server
61 HttpServer::new(move || {
62 App::new()
63 // store db pool as Data object
64 .app_data(web::Data::new(pool.clone()))
65 .wrap(middleware::Logger::default())
66 .service(web::resource("/asyncio_weather").route(web::get().to(asyncio_weather)))
67 .service(web::resource("/parallel_weather").route(web::get().to(parallel_weather)))
68 })
69 .bind(("127.0.0.1", 8080))?
70 .workers(2)
71 .run()
72 .await
73}

Callers

nothing calls this directly

Calls 1

runMethod · 0.80

Tested by

no test coverage detected