From d982951ec15326487eefa80261a0f466d64e2ba0 Mon Sep 17 00:00:00 2001 From: xengineering Date: Wed, 1 May 2024 10:56:26 +0200 Subject: view: Add /version endpoint This allows to get the server version via HTTP. The output of `git describe --dirty --always` and a line break is returned together with HTTP 200. If the server build contains no version information an error message and HTTP 404 is returned. --- main.go | 2 ++ 1 file changed, 2 insertions(+) (limited to 'main.go') diff --git a/main.go b/main.go index 2c39239..50cfce5 100644 --- a/main.go +++ b/main.go @@ -59,6 +59,8 @@ func startServer(addr string) *http.Server { r.PathPrefix("/static/"). Handler(http.StripPrefix("/static/", http.FileServer(http.FS(static)))) + r.HandleFunc("/version", view.VersionRead(gitDescribe)).Methods(`GET`) + r.HandleFunc("/recipes", view.RecipesRead).Methods(`GET`) r.HandleFunc("/recipe", controller.RecipeCreate).Methods(`POST`) -- cgit v1.2.3-70-g09d2