From 5a1a68c732369a8fb047be8c306770801d3e9506 Mon Sep 17 00:00:00 2001 From: Jonny Stoten Date: Tue, 11 Jun 2024 11:16:11 +0100 Subject: [PATCH] Use http method in route pattern --- main.go | 2 +- pkg/handler/handler.go | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/main.go b/main.go index c51664d..8c82df6 100644 --- a/main.go +++ b/main.go @@ -38,7 +38,7 @@ func init() { func main() { mux := http.NewServeMux() - mux.HandleFunc("/", handler.Handler) + mux.HandleFunc("POST /", handler.Handler) server := &http.Server{ Addr: fmt.Sprintf(":%d", port), diff --git a/pkg/handler/handler.go b/pkg/handler/handler.go index fa8b03a..9011a98 100644 --- a/pkg/handler/handler.go +++ b/pkg/handler/handler.go @@ -19,11 +19,6 @@ import ( ) func Handler(w http.ResponseWriter, req *http.Request) { - // only accept POST requests - if req.Method != http.MethodPost { - utils.SendResponse(nil, "only POST is allowed", w) - return - } // read request body requestBody, err := io.ReadAll(req.Body)