I am very new to Go, infact started today. But have run into a weird and frustrating problem. Simply put, the following code prints r.Method
as GET when I make a POST request via POSTMAN.
package main
import (
"fmt"
"net/http"
"routes"
)
func cartHandler(w http.ResponseWriter, r *http.Request) {
fmt.Printf(r.Method);
if r.Method == "GET" {
cart.GetHandler(w,r)
} else if r.Method == "POST" {
cart.PostHandler(w,r)
}
//fmt.Fprintf(w, "Hi there, I love %s!", r.Method)
}
func main() {
http.HandleFunc("/cart/", cartHandler)
http.ListenAndServe(":8010", nil)
}
The request being made is fine because a similar piece of code in nodejs detects it as a POST request.