From 1fc926a989be4675a236fae325fbb10d2e10ef58 Mon Sep 17 00:00:00 2001 From: Aadi Desai <21363892+supleed2@users.noreply.github.com> Date: Wed, 25 Oct 2023 00:29:27 +0100 Subject: [PATCH] Add `/up` endpoint for uptime monitoring --- src/main.rs | 22 ++++++++++++---------- src/routes.rs | 7 ++++++- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/main.rs b/src/main.rs index dd05798..5199dbb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -115,16 +115,18 @@ async fn poise( tracing::info!("Secrets loaded"); // Build Axum Router - let router = axum::Router::new().route( - "/verify", - axum::routing::post({ - let pool = pool.clone(); - let key = secret_store - .get("VERIFY_KEY") - .context("VERIFY_KEY not found")?; - move |body| routes::verify(pool, body, key) - }), - ); + let router = axum::Router::new() + .route("/up", axum::routing::get(routes::up)) + .route( + "/verify", + axum::routing::post({ + let pool = pool.clone(); + let key = secret_store + .get("VERIFY_KEY") + .context("VERIFY_KEY not found")?; + move |body| routes::verify(pool, body, key) + }), + ); // Build Poise Instance let discord = poise::Framework::builder() diff --git a/src/routes.rs b/src/routes.rs index d1ab929..7bc9af8 100644 --- a/src/routes.rs +++ b/src/routes.rs @@ -1,7 +1,12 @@ use crate::PendingMember; use axum::{http::StatusCode, response::IntoResponse, Json}; -#[derive(serde::Deserialize, serde::Serialize)] +#[tracing::instrument] +pub(crate) async fn up() -> impl IntoResponse { + (StatusCode::OK, "Nano is up!") +} + +#[derive(serde::Deserialize)] pub(crate) struct Verify { id: String, shortcode: String,