From 06ac95876cf1378bc5f3db5ac6c27c564327ea53 Mon Sep 17 00:00:00 2001 From: Ellie Huxtable Date: Mon, 6 Jun 2022 09:58:19 +0100 Subject: [PATCH] Show current version on server index (#436) --- atuin-server/src/handlers/mod.rs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/atuin-server/src/handlers/mod.rs b/atuin-server/src/handlers/mod.rs index cfe08bc..4aa7423 100644 --- a/atuin-server/src/handlers/mod.rs +++ b/atuin-server/src/handlers/mod.rs @@ -6,8 +6,21 @@ use serde::{Deserialize, Serialize}; pub mod history; pub mod user; -pub async fn index() -> &'static str { - "\"Through the fathomless deeps of space swims the star turtle Great A\u{2019}Tuin, bearing on its back the four giant elephants who carry on their shoulders the mass of the Discworld.\"\n\t-- Sir Terry Pratchett" +const VERSION: &str = env!("CARGO_PKG_VERSION"); + +#[derive(Debug, Serialize, Deserialize)] +pub struct IndexResponse { + pub homage: String, + pub version: String, +} + +pub async fn index() -> Json { + let homage = r#""Through the fathomless deeps of space swims the star turtle Great A'Tuin, bearing on its back the four giant elephants who carry on their shoulders the mass of the Discworld." -- Sir Terry Pratchett"#; + + Json(IndexResponse { + homage: homage.to_string(), + version: VERSION.to_string(), + }) } #[derive(Debug, Serialize, Deserialize)]