Skip to content
This repository has been archived by the owner on Mar 18, 2023. It is now read-only.

Commit

Permalink
✨ Add /api/health
Browse files Browse the repository at this point in the history
  • Loading branch information
eigenein committed Nov 12, 2022
1 parent 0557928 commit a8344e4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ async fn create_standalone_app() -> Result<impl Endpoint> {
.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())
Expand Down
1 change: 1 addition & 0 deletions src/web/views.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pub mod api;
pub mod error;
pub mod gone;
pub mod index;
Expand Down
12 changes: 12 additions & 0 deletions src/web/views/api.rs
Original file line number Diff line number Diff line change
@@ -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<impl IntoResponse> {
Ok(Response::from(StatusCode::NO_CONTENT).with_header("Cache-Control", CACHE_CONTROL))
}

0 comments on commit a8344e4

Please sign in to comment.