Skip to content

Instantly share code, notes, and snippets.

@tjmaynes
Created October 12, 2021 18:08
Show Gist options
  • Save tjmaynes/a72b1d661c9d3d2c55f66901195c37b1 to your computer and use it in GitHub Desktop.
Save tjmaynes/a72b1d661c9d3d2c55f66901195c37b1 to your computer and use it in GitHub Desktop.
...
let app_state = web::Data::new(AppState {
db_conn: db_conn
});
HttpServer::new(move || {
App::new()
.app_data(app_state.clone()) // <- cloned app_state variable
.route("/health", web::get().to(get_health_status))
})
.bind(("127.0.0.1", 8080))?
.run()
.await
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment