From 4aab6baebbc97cd17d6f13edf9a186169afbc9c6 Mon Sep 17 00:00:00 2001 From: Scott Lamb Date: Wed, 27 Oct 2021 13:09:20 -0700 Subject: [PATCH] add server version to /api response Fixes #171 --- design/api.md | 1 + server/src/json.rs | 2 ++ server/src/web.rs | 1 + 3 files changed, 4 insertions(+) diff --git a/design/api.md b/design/api.md index 6f29511..5a412a9 100644 --- a/design/api.md +++ b/design/api.md @@ -86,6 +86,7 @@ The `application/json` response will have a JSON object as follows: * `timeZoneName`: the name of the IANA time zone the server is using to divide recordings into days as described further below. +* `serverVersion`: the version of the server in use, eg `0.7.0`. * `cameras`: a list of cameras. Each is a JSON object as follows: * `uuid`: in text format * `id`: an integer. The client doesn't ever need to send the id diff --git a/server/src/json.rs b/server/src/json.rs index a9d9e4a..c5de41e 100644 --- a/server/src/json.rs +++ b/server/src/json.rs @@ -15,6 +15,8 @@ use uuid::Uuid; pub struct TopLevel<'a> { pub time_zone_name: &'a str, + pub server_version: &'static str, + // Use a custom serializer which presents the map's values as a sequence and includes the // "days" and "camera_configs" attributes or not, according to the respective bools. #[serde(serialize_with = "TopLevel::serialize_cameras")] diff --git a/server/src/web.rs b/server/src/web.rs index 6defe51..5fb4e66 100644 --- a/server/src/web.rs +++ b/server/src/web.rs @@ -679,6 +679,7 @@ impl Service { req, &json::TopLevel { time_zone_name: &self.time_zone_name, + server_version: env!("CARGO_PKG_VERSION"), cameras: (&db, days, camera_configs), user: caller.user, signals: (&db, days),