Add /up endpoint for uptime monitoring

This commit is contained in:
Aadi Desai 2023-10-25 00:29:27 +01:00
parent 125dca39b9
commit 1fc926a989
Signed by: supleed2
SSH key fingerprint: SHA256:CkbNRs0yVzXEiUp2zd0PSxsfRUMFF9bLlKXtE1xEbKM
2 changed files with 18 additions and 11 deletions

View file

@ -115,16 +115,18 @@ async fn poise(
tracing::info!("Secrets loaded"); tracing::info!("Secrets loaded");
// Build Axum Router // Build Axum Router
let router = axum::Router::new().route( let router = axum::Router::new()
"/verify", .route("/up", axum::routing::get(routes::up))
axum::routing::post({ .route(
let pool = pool.clone(); "/verify",
let key = secret_store axum::routing::post({
.get("VERIFY_KEY") let pool = pool.clone();
.context("VERIFY_KEY not found")?; let key = secret_store
move |body| routes::verify(pool, body, key) .get("VERIFY_KEY")
}), .context("VERIFY_KEY not found")?;
); move |body| routes::verify(pool, body, key)
}),
);
// Build Poise Instance // Build Poise Instance
let discord = poise::Framework::builder() let discord = poise::Framework::builder()

View file

@ -1,7 +1,12 @@
use crate::PendingMember; use crate::PendingMember;
use axum::{http::StatusCode, response::IntoResponse, Json}; 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 { pub(crate) struct Verify {
id: String, id: String,
shortcode: String, shortcode: String,