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

Function main

databases/postgres/src/main.rs:41–64  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

39
40#[actix_web::main]
41async fn main() -> std::io::Result<()> {
42 unsafe { dotenv() }.ok();
43
44 let config = ExampleConfig::builder()
45 .override_with(EnvSource::new())
46 .try_build()
47 .unwrap();
48
49 let pool = config.pg.create_pool(None, NoTls).unwrap();
50
51 let server = HttpServer::new(move || {
52 App::new().app_data(web::ThinData(pool.clone())).service(
53 web::resource("/users")
54 .route(web::post().to(add_user))
55 .route(web::get().to(get_users)),
56 )
57 })
58 .bind(config.server_addr.clone())?
59 .run();
60
61 println!("Server running at http://{}/", config.server_addr);
62
63 server.await
64}

Callers

nothing calls this directly

Calls 2

postFunction · 0.85
runMethod · 0.80

Tested by

no test coverage detected