openzeppelin_relayer/api/routes/
health.rs1use actix_web::{get, web, HttpResponse};
5
6#[utoipa::path(
13 get,
14 path = "/v1/health",
15 tag = "Health",
16 responses(
17 (status = 200, description = "Service is healthy", body = String),
18 (status = 500, description = "Internal server error", body = String),
19 )
20)]
21#[get("/health")]
22async fn health() -> Result<HttpResponse, actix_web::Error> {
23 Ok(HttpResponse::Ok().body("OK"))
24}
25
26pub fn init(cfg: &mut web::ServiceConfig) {
30 cfg.service(health);
31}
32
33#[cfg(test)]
34mod tests {
35 use super::*;
36 use actix_web::{test, App};
37
38 #[actix_web::test]
39 async fn test_health_endpoint() {
40 let app = test::init_service(App::new().configure(init)).await;
42
43 let req = test::TestRequest::get().uri("/health").to_request();
45 let resp = test::call_service(&app, req).await;
46
47 assert!(resp.status().is_success());
49
50 let body = test::read_body(resp).await;
51 assert_eq!(body, "OK");
52 }
53}