I'm learning golang and tried to implement a custom mix to get familiar with the language, unfortunately req.Form
is returning nil
.
Of course I'm running before req.ParseForm()
.
func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request) {
req.ParseForm()
params := req.Form
node, _ := r.tree.findNode(strings.Split(req.URL.Path, "/")[1:], params)
if handler := node.methods[req.Method]; handler != nil {
handler(w, req, params)
}
}
This is the example URL I'm using via GET http://localhost:8080/users/3