apub_inbox
: Add /.healthcheck
route
This commit is contained in:
parent
f1fd63d13a
commit
e72fa092fb
2 changed files with 15 additions and 0 deletions
|
@ -16,6 +16,7 @@ async fn main() -> anyhow::Result<std::convert::Infallible> {
|
||||||
|
|
||||||
log::trace!("Creating Axum router...");
|
log::trace!("Creating Axum router...");
|
||||||
let app = axum::Router::new()
|
let app = axum::Router::new()
|
||||||
|
.route("/.healthcheck", axum::routing::get(route::healthcheck_handler))
|
||||||
.layer(Extension(Arc::new(mj)));
|
.layer(Extension(Arc::new(mj)));
|
||||||
log::trace!("Axum router created successfully!");
|
log::trace!("Axum router created successfully!");
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
use axum::http::StatusCode;
|
||||||
|
use acrate_database::connect::connect_async;
|
||||||
|
|
||||||
|
pub async fn healthcheck_handler() -> Result<StatusCode, StatusCode> {
|
||||||
|
log::debug!("Handling an healthcheck request!");
|
||||||
|
|
||||||
|
log::trace!("Making sure the database is up...");
|
||||||
|
let _conn = connect_async()
|
||||||
|
.await
|
||||||
|
.map_err(|_| StatusCode::BAD_GATEWAY)?;
|
||||||
|
|
||||||
|
log::trace!("Healthcheck successful! Everything's fine!");
|
||||||
|
Ok(StatusCode::NO_CONTENT)
|
||||||
|
}
|
Loading…
Reference in a new issue