From 89a2845ab18975c3d398393bf04e06df6fa04822 Mon Sep 17 00:00:00 2001 From: nagdahimanshu Date: Fri, 28 Jun 2024 10:27:39 +0200 Subject: [PATCH] Add endpoint for health check --- internal/server/server.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/internal/server/server.go b/internal/server/server.go index f75f6c37..83233549 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -32,6 +32,7 @@ func NewServer(builder chain.TxBuilder, cfg *Config) *Server { func (s *Server) setupRouter() *http.ServeMux { router := http.NewServeMux() router.Handle("/", http.FileServer(web.Dist())) + router.Handle("/health", s.handleHealthCheck()) limiter := NewLimiter(s.cfg.proxyCount, time.Duration(s.cfg.interval)*time.Minute) hcaptcha := NewCaptcha(s.cfg.hcaptchaSiteKey, s.cfg.hcaptchaSecret) router.Handle("/api/claim", negroni.New(limiter, hcaptcha, negroni.Wrap(s.handleClaim()))) @@ -95,3 +96,10 @@ func (s *Server) handleInfo() http.HandlerFunc { }, http.StatusOK) } } + +func (s *Server) handleHealthCheck() http.HandlerFunc { + return func(w http.ResponseWriter, _ *http.Request) { + //nolint:errcheck + w.Write([]byte("OK")) + } +}