diff options
| author | xengineering <me@xengineering.eu> | 2024-05-01 10:56:26 +0200 | 
|---|---|---|
| committer | xengineering <me@xengineering.eu> | 2024-05-01 10:56:26 +0200 | 
| commit | d982951ec15326487eefa80261a0f466d64e2ba0 (patch) | |
| tree | 9506833546ea177b4bf985e39981153ae914a8fc /view | |
| parent | 01699e3c9339cd7880f632be088d770225b84d68 (diff) | |
| download | ceres-d982951ec15326487eefa80261a0f466d64e2ba0.tar ceres-d982951ec15326487eefa80261a0f466d64e2ba0.tar.zst ceres-d982951ec15326487eefa80261a0f466d64e2ba0.zip  | |
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.
Diffstat (limited to 'view')
| -rw-r--r-- | view/version.go | 17 | 
1 files changed, 17 insertions, 0 deletions
diff --git a/view/version.go b/view/version.go new file mode 100644 index 0000000..faf91b1 --- /dev/null +++ b/view/version.go @@ -0,0 +1,17 @@ +package view + +import ( +	"fmt" +	"net/http" +) + +func VersionRead(version string) func(http.ResponseWriter, *http.Request) { +	return func(w http.ResponseWriter, r *http.Request) { +		if version == "" { +			http.Error(w, "This build has no version information", http.StatusNotFound) +			return +		} + +		fmt.Fprintln(w, version) +	} +}  | 
