Use http method in route pattern

This commit is contained in:
Jonny Stoten
2024-06-11 11:16:11 +01:00
parent db036df9d5
commit 5a1a68c732
2 changed files with 1 additions and 6 deletions

View File

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

View File

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