chore: separate backend from frontend
Some checks failed
Publish Docker Images / build-and-publish (push) Failing after 9m29s
Some checks failed
Publish Docker Images / build-and-publish (push) Failing after 9m29s
This commit is contained in:
38
src/route/health.rs
Normal file
38
src/route/health.rs
Normal file
@@ -0,0 +1,38 @@
|
||||
//! Health check endpoint for monitoring service availability.
|
||||
|
||||
use poem_openapi::{ApiResponse, OpenApi};
|
||||
|
||||
use super::ApiCategory;
|
||||
|
||||
#[derive(ApiResponse)]
|
||||
enum HealthResponse {
|
||||
/// Success
|
||||
#[oai(status = 200)]
|
||||
Ok,
|
||||
/// Too Many Requests - rate limit exceeded
|
||||
#[oai(status = 429)]
|
||||
#[allow(dead_code)]
|
||||
TooManyRequests,
|
||||
}
|
||||
|
||||
/// Health check API for monitoring service availability.
|
||||
#[derive(Default, Clone)]
|
||||
pub struct HealthApi;
|
||||
|
||||
#[OpenApi(tag = "ApiCategory::Health")]
|
||||
impl HealthApi {
|
||||
#[oai(path = "/health", method = "get")]
|
||||
async fn ping(&self) -> HealthResponse {
|
||||
tracing::event!(target: "backend::health", tracing::Level::DEBUG, "Accessing health-check endpoint");
|
||||
HealthResponse::Ok
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn health_check_works() {
|
||||
let app = crate::get_test_app();
|
||||
let cli = poem::test::TestClient::new(app);
|
||||
let resp = cli.get("/api/health").send().await;
|
||||
resp.assert_status_is_ok();
|
||||
resp.assert_text("").await;
|
||||
}
|
||||
Reference in New Issue
Block a user