From b405df26013d1bd81d0778c75374e340a9a620d4 Mon Sep 17 00:00:00 2001 From: Gustav Behm Date: Sun, 21 Jul 2024 06:46:20 +0200 Subject: [PATCH] Respond with 204 on HEAD / requests --- http/http.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/http/http.go b/http/http.go index d0a1838a..e33ddea5 100644 --- a/http/http.go +++ b/http/http.go @@ -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)