add health endpoint (#326)

V3_GIT_ORIGIN_REV_ID: c2868238d43045e65b30df4dff4bc909a4999a17
This commit is contained in:
paritosh-08 2024-02-27 14:44:39 +05:30 committed by hasura-bot
parent 64bb9c873d
commit 5c9033a66a

View File

@ -125,11 +125,14 @@ async fn start_engine(server: &ServerOptions) -> Result<(), StartupError> {
.layer(TraceLayer::new_for_http())
.with_state(state.clone());
let health_route = Router::new().route("/health", get(handle_health));
let app = Router::new()
// serve graphiql at root
.route("/", get(graphiql))
.merge(graphql_route)
.merge(explain_route);
.merge(explain_route)
.merge(health_route);
let addr = format!("0.0.0.0:{}", server.port.unwrap_or(3000));
@ -146,6 +149,11 @@ async fn start_engine(server: &ServerOptions) -> Result<(), StartupError> {
Ok(())
}
/// Health check endpoint
async fn handle_health() -> reqwest::StatusCode {
reqwest::StatusCode::OK
}
/// Middleware to start tracing of the `/graphql` request.
/// This middleware must be active for the entire duration
/// of the request i.e. this middleware should be the