Skip to content

Commit

Permalink
feat: add /health handler
Browse files Browse the repository at this point in the history
  • Loading branch information
maier committed Jan 6, 2023
1 parent 215c117 commit d8e4a88
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions internal/server/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ func (genericHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
http.Error(w, "not found", http.StatusNotFound)
}

type healthHandler struct{}

func (healthHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
_, _ = w.Write([]byte("OK"))
}

type bulkHandler struct {
log logger.Logger
metrics *trapmetrics.TrapMetrics
Expand Down
1 change: 1 addition & 0 deletions internal/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ func New(cfg *config.Config) (*Server, error) {

mux := http.NewServeMux()
mux.Handle("/", genericHandler{})
mux.Handle("/health", healthHandler{})
mux.Handle("/_bulk", http.TimeoutHandler(bulkHandler{
dest: cfg.Destination,
log: logger.LogWrapper{
Expand Down

0 comments on commit d8e4a88

Please sign in to comment.