@@ -16,11 +16,6 @@ const applicationJSON = "application/json"
16
16
const hostnameKey = "hostname"
17
17
const wildcard = "*"
18
18
19
- func healthCheck (w http.ResponseWriter , _ * http.Request ) {
20
- w .Header ().Set (contentType , applicationJSON )
21
- _ , _ = fmt .Fprintf (w , `{"status": "ok"}` )
22
- }
23
-
24
19
func getVersion (w http.ResponseWriter , _ * http.Request ) {
25
20
w .Header ().Set (contentType , applicationJSON )
26
21
_ , _ = fmt .Fprintf (w , `{"version": "%s", "build_time": "%s", "build_user": "%s"}` , app .Info .Version , app .Info .BuildTime , app .Info .BuildUser )
@@ -32,6 +27,21 @@ func prometheusMetrics(h http.Handler) http.HandlerFunc {
32
27
}
33
28
}
34
29
30
+ func (m * Manager ) healthCheck (w http.ResponseWriter , _ * http.Request ) {
31
+ w .Header ().Set (contentType , applicationJSON )
32
+ _ , _ = fmt .Fprintf (w , `{"status": "ok"}` )
33
+ }
34
+
35
+ func (m * Manager ) readyCheck (w http.ResponseWriter , _ * http.Request ) {
36
+ w .Header ().Set (contentType , applicationJSON )
37
+ if m .reports .HasValidBuild () {
38
+ _ , _ = fmt .Fprintf (w , `{"status": "ok"}` )
39
+ } else {
40
+ w .WriteHeader (http .StatusServiceUnavailable )
41
+ _ , _ = fmt .Fprintf (w , `{"status": "not ready"}` )
42
+ }
43
+ }
44
+
35
45
// getAFKEnabled endpoint returns all AFK enabled devices.
36
46
// They are supposed to be managed by AFK, meaning the configuration should be applied periodically.
37
47
func (m * Manager ) getAFKEnabled (w http.ResponseWriter , r * http.Request ) {
0 commit comments