From 4c242ea21170d461281a2536ba5f97b2b0876379 Mon Sep 17 00:00:00 2001 From: Oluwatobi Bamidele Date: Thu, 14 Nov 2024 17:10:33 +0100 Subject: [PATCH] feat: health endpoint --- src/routes.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/routes.rs b/src/routes.rs index 5cf228db..e804f9c2 100644 --- a/src/routes.rs +++ b/src/routes.rs @@ -41,6 +41,7 @@ pub async fn launch_rocket( check_challenge, get_signup_challenge, check_signup_challenge, + service_health, ], ) .attach(CORS) @@ -147,6 +148,12 @@ pub struct ChallengeStatusResponse { pub message: String, } +#[derive(Serialize)] +#[serde(crate = "rocket::serde")] +pub struct ServiceHealthResponse { + pub status: String, +} + #[derive(Serialize)] #[serde(crate = "rocket::serde")] pub struct GetChallengeResponse { @@ -332,3 +339,11 @@ pub async fn check_signup_challenge( } Ok(reply) } + +// /health +#[get("/health")] +pub async fn service_health() -> Result> { + Ok(Json(ServiceHealthResponse { + status: "ok".to_string(), + })) +}