Respond with 204 on HEAD / requests

This commit is contained in:
Gustav Behm 2024-07-21 06:46:20 +02:00
parent d84665c26c
commit b405df2601
No known key found for this signature in database
GPG Key ID: 66F5712F65909FFF

View File

@ -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 {
@ -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)