Skip to content

Commit

Permalink
Respond with 204 on HEAD / requests
Browse files Browse the repository at this point in the history
  • Loading branch information
rootmos committed Oct 25, 2024
1 parent d84665c commit b405df2
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,12 @@ func (s *Server) HealthHandler(w http.ResponseWriter, r *http.Request) *appError
return nil
}

func (s *Server) HeadHandler(w http.ResponseWriter, r *http.Request) *appError {
return &appError{
Code: http.StatusNoContent,
}
}

func (s *Server) PortHandler(w http.ResponseWriter, r *http.Request) *appError {
response, err := s.newPortResponse(r)
if err != nil {
Expand Down Expand Up @@ -426,6 +432,9 @@ func (s *Server) Handler() http.Handler {
// Health
r.Route("GET", "/health", s.HealthHandler)

// Health
r.Route("HEAD", "/", s.HeadHandler)

// JSON
r.Route("GET", "/", s.JSONHandler).Header("Accept", jsonMediaType)
r.Route("GET", "/json", s.JSONHandler)
Expand Down

0 comments on commit b405df2

Please sign in to comment.