1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
use async_std::task; use stratum_types::Result; use tide::Response; //The <> here is state, so add to it as we need it. pub async fn init_api_server() -> Result<()> { let mut app = tide::new(); app.at("/ping").get(health_check); task::spawn(async move { app.listen("127.0.0.1:8081").await.unwrap() }); Ok(()) } async fn health_check(_req: tide::Request<()>) -> Response { Response::new(200) } //@todo 2 checks we want here. //1. Basic healthcheck, literally just an http endoint /ping that returns 200 //2. More complex that checks all dependent services are working. That might be able to be saved by // whatever is implementing this above, but we can brainstorm more on this one.