use actix_web::{get, web, HttpResponse, Responder};
use chrono::{Local, Utc};
pub fn configure(config: &mut web::ServiceConfig) {
config.service(health_url).service(now_url);
}
#[utoipa::path(
get,
operation_id = "check_service_health",
context_path = "/health",
responses(
(
status = 200,
description = "Health check passed.",
body = String,
),
),
)]
#[get("")]
pub async fn health_url() -> impl Responder {
HttpResponse::Ok().body("success".to_string())
}
#[utoipa::path(
get,
operation_id = "get_server_datetime",
context_path = "/health",
responses(
(
status = 200,
description = "The current datetime with timezone.",
body = String,
),
),
)]
#[get("/now")]
pub async fn now_url() -> impl Responder {
HttpResponse::Ok().body(Utc::now().with_timezone(&Local).to_string())
}