Skip to content

Commit

Permalink
Add endpoint for health check (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
nagdahimanshu authored Jun 28, 2024
1 parent dbd646a commit 53b561a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions internal/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())))
Expand Down Expand Up @@ -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"))
}
}

0 comments on commit 53b561a

Please sign in to comment.