From 243b719ae2fe25043be338170ca2c196536643c3 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Wed, 30 Jul 2025 10:04:15 -0300 Subject: [PATCH] feat: support HEAD request (#7) --- main.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 564caa4fc2e5fb628e7f973682bd8dbd2077d7eb..7da125f8c74f215030c16c2df6355baec38d7cc2 100644 --- a/main.go +++ b/main.go @@ -22,6 +22,11 @@ var counter = promauto.NewCounter(prometheus.CounterOpts{ }) func providersHandler(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "application/json") + if r.Method == http.MethodHead { + return + } + if r.Method != http.MethodGet { http.Error(w, "Method not allowed", http.StatusMethodNotAllowed) return @@ -29,7 +34,6 @@ func providersHandler(w http.ResponseWriter, r *http.Request) { counter.Inc() allProviders := providers.GetAll() - w.Header().Set("Content-Type", "application/json") if err := json.NewEncoder(w).Encode(allProviders); err != nil { http.Error(w, "Internal server error", http.StatusInternalServerError) return