Server: Add health check route (#26999)
* Server: Add health check route Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com> * Server: Remove health check middleware Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
This commit is contained in:
@@ -435,5 +435,8 @@ func (hs *HTTPServer) registerRoutes() {
|
||||
r.Get("/api/snapshots-delete/:deleteKey", reqSnapshotPublicModeOrSignedIn, Wrap(DeleteDashboardSnapshotByDeleteKey))
|
||||
r.Delete("/api/snapshots/:key", reqEditorRole, Wrap(DeleteDashboardSnapshot))
|
||||
|
||||
// Health check
|
||||
r.Get("/api/health", hs.healthHandler)
|
||||
|
||||
r.Get("/*", reqSignedIn, hs.Index)
|
||||
}
|
||||
|
||||
@@ -324,7 +324,6 @@ func (hs *HTTPServer) addMiddlewaresAndStaticRoutes() {
|
||||
Delims: macaron.Delims{Left: "[[", Right: "]]"},
|
||||
}))
|
||||
|
||||
m.Use(hs.healthHandler)
|
||||
m.Use(hs.metricsEndpoint)
|
||||
m.Use(middleware.GetContextHandler(
|
||||
hs.AuthTokenService,
|
||||
@@ -386,7 +385,12 @@ func (hs *HTTPServer) healthHandler(ctx *macaron.Context) {
|
||||
ctx.Resp.WriteHeader(200)
|
||||
}
|
||||
|
||||
dataBytes, _ := data.EncodePretty()
|
||||
dataBytes, err := data.EncodePretty()
|
||||
if err != nil {
|
||||
hs.log.Error("Failed to encode data", "err", err)
|
||||
return
|
||||
}
|
||||
|
||||
if _, err := ctx.Resp.Write(dataBytes); err != nil {
|
||||
hs.log.Error("Failed to write to response", "err", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user