diff --git a/src/web.rs b/src/web.rs index d4b813a6..a65225b9 100644 --- a/src/web.rs +++ b/src/web.rs @@ -119,6 +119,7 @@ async fn create_standalone_app() -> Result { .at("/error", get(views::error::get_error)) .at("/random", get(views::random::get_random)) .at("/sitemaps/:realm/sitemap.txt", get(views::sitemaps::get_sitemap)) + .at("/api/health", get(views::api::get_health)) .data(i18n::build_resources()?) .with(Tracing) .with(CatchPanic::new()) diff --git a/src/web/views.rs b/src/web/views.rs index f9a675c2..63cf4f8f 100644 --- a/src/web/views.rs +++ b/src/web/views.rs @@ -1,3 +1,4 @@ +pub mod api; pub mod error; pub mod gone; pub mod index; diff --git a/src/web/views/api.rs b/src/web/views/api.rs new file mode 100644 index 00000000..2fbb38b0 --- /dev/null +++ b/src/web/views/api.rs @@ -0,0 +1,12 @@ +use poem::http::StatusCode; +use poem::{handler, IntoResponse, Response}; + +use crate::prelude::*; + +const CACHE_CONTROL: &str = "no-cache"; + +#[handler] +#[instrument(skip_all, level = "info")] +pub async fn get_health() -> Result { + Ok(Response::from(StatusCode::NO_CONTENT).with_header("Cache-Control", CACHE_CONTROL)) +}