From ffd415f89bab32a6dd78b97f7cfc584e71a02f6e Mon Sep 17 00:00:00 2001 From: Hannes Klinckaert Date: Thu, 24 Oct 2024 13:42:56 +0200 Subject: [PATCH] vingo: add backend version endpoint --- vingo/src/main.rs | 3 ++- vingo/src/routes/info.rs | 12 ++++++++++++ vingo/src/routes/mod.rs | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 vingo/src/routes/info.rs diff --git a/vingo/src/main.rs b/vingo/src/main.rs index 73950cf..0341d2a 100644 --- a/vingo/src/main.rs +++ b/vingo/src/main.rs @@ -8,7 +8,7 @@ use std::{ }; use chrono::Local; -use routes::{auth, cards, days, leaderboard, scans, seasons, settings}; +use routes::{auth, cards, days, info, leaderboard, scans, seasons, settings}; use axum::{ middleware::from_fn, @@ -102,6 +102,7 @@ fn open_routes() -> Router { .route("/login", post(auth::login)) .route("/auth/callback", get(auth::callback)) .route("/scans", post(scans::add)) + .route("/version", get(info::version)) } fn authenticated_routes() -> Router { diff --git a/vingo/src/routes/info.rs b/vingo/src/routes/info.rs new file mode 100644 index 0000000..fcc1bef --- /dev/null +++ b/vingo/src/routes/info.rs @@ -0,0 +1,12 @@ +use axum::Json; +use serde::{Deserialize, Serialize}; + +#[derive(Serialize, Deserialize)] +pub struct Version { + version: String, +} +pub async fn version() -> Json { + return Json(Version { + version: env!("CARGO_PKG_VERSION").to_string(), + }); +} diff --git a/vingo/src/routes/mod.rs b/vingo/src/routes/mod.rs index 45e62ef..b7fa9ba 100644 --- a/vingo/src/routes/mod.rs +++ b/vingo/src/routes/mod.rs @@ -1,6 +1,7 @@ pub mod auth; pub mod cards; pub mod days; +pub mod info; pub mod leaderboard; pub mod scans; pub mod seasons;