This repository was archived by the owner on Dec 26, 2024. It is now read-only.
File tree 2 files changed +35
-0
lines changed
2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,7 @@ func (s Server) Handler() http.Handler {
49
49
r .Use (middleware .Logger )
50
50
51
51
r .Route ("/api/healthz" , newHealthHandler ().Routes )
52
+ r .Route ("/api/version" , newVersionHandler ().Routes )
52
53
53
54
r .Group (func (r chi.Router ) {
54
55
r .Use (s .isAuthenticated )
Original file line number Diff line number Diff line change
1
+ package http
2
+
3
+ import (
4
+ "net/http"
5
+
6
+ "github.com/autobrr/omegabrr/internal/buildinfo"
7
+ "github.com/go-chi/chi/v5"
8
+ "github.com/go-chi/render"
9
+ )
10
+
11
+ type versionHandler struct {}
12
+
13
+ func newVersionHandler () * versionHandler {
14
+ return & versionHandler {}
15
+ }
16
+
17
+ func (h versionHandler ) Routes (r chi.Router ) {
18
+ r .Get ("/" , h .handleVersion )
19
+ }
20
+
21
+ type VersionResponse struct {
22
+ Version string `json:"version"`
23
+ Commit string `json:"commit"`
24
+ Date string `json:"date"`
25
+ }
26
+
27
+ func (h versionHandler ) handleVersion (w http.ResponseWriter , r * http.Request ) {
28
+ resp := VersionResponse {
29
+ Version : buildinfo .Version ,
30
+ Commit : buildinfo .Commit ,
31
+ Date : buildinfo .Date ,
32
+ }
33
+ render .JSON (w , r , resp )
34
+ }
You can’t perform that action at this time.
0 commit comments