From 78f50f24b3ff87f5f1e0227e2cdd2599a39add82 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Sun, 16 Jun 2024 10:00:56 +0000 Subject: feat(index.html): show version if available --- src/request.gleam | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/request.gleam b/src/request.gleam index d9abccf..6e23caf 100644 --- a/src/request.gleam +++ b/src/request.gleam @@ -1,5 +1,7 @@ import database +import envoy import gleam/json +import gleam/string import gleam/string_builder import simplifile import svg @@ -22,7 +24,17 @@ pub fn handle(request, connection) { [] -> case simplifile.read("index.html") { Ok(content) -> - wisp.html_response(string_builder.from_string(content), 200) + wisp.html_response( + string_builder.from_string( + string.replace(content, "{{ MAYU_VERSION }}", case + envoy.get("MAYU_VERSION") + { + Ok(version) -> "(v" <> version <> ")" + Error(_) -> "" + }), + ), + 200, + ) Error(_) -> wisp.not_found() } ["heart-beat"] -> -- cgit v1.2.3