Add healtcheck endpoint
This commit is contained in:
@@ -96,6 +96,7 @@ func NewServer(cfg config.FrontendConfig, hs *ssh.HoneypotServer, store store.Lo
|
||||
r.Get("/stats", s.HandlerStats)
|
||||
r.Get("/stream", s.HandlerAttemptStream)
|
||||
r.Get("/query", s.HandlerQuery)
|
||||
r.Get("/health", s.HandlerHealth)
|
||||
})
|
||||
})
|
||||
s.Handler = r
|
||||
@@ -273,6 +274,15 @@ func (s *Server) HandlerQuery(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) HandlerHealth(w http.ResponseWriter, r *http.Request) {
|
||||
err := s.store.IsHealthy()
|
||||
if err != nil {
|
||||
s.WriteAPIError(w, r, http.StatusInternalServerError, fmt.Sprintf("Health error: %s", err))
|
||||
return
|
||||
}
|
||||
w.Write([]byte(`{}`))
|
||||
}
|
||||
|
||||
type APIErrorResponse struct {
|
||||
Error string `json:"error"`
|
||||
}
|
||||
|
Reference in New Issue
Block a user