I'm using Gorilla Mux to handle my HTTP routes for my REST API. I'm using the following binding for my API:
r := mux.NewRouter()
r.Host(baseUrl)
api := r.PathPrefix("/api").Subrouter()
api.HandleFunc("/users", APIUsers).Methods("GET", "POST")
http.Handle("/", r)
http.ListenAndServe(":8083", nil)
Then I do a CURL like this:
$ curl -i -X PUT http://127.0.0.1:8083/api/users
The Method APIUsers
doesn't get called, as expected. I do get a 200 OK
back tho:
HTTP/1.1 200 OK
Date: Tue, 30 Dec 2014 19:03:59 GMT
Content-Length: 0
Content-Type: text/plain; charset=utf-8
Should I do this different with Gorilla to, let's say, bind all failing functions to a designated function? Also I wonder what's the typical HTTP code to return on non-supported functions. I'm a assuming a code in the 400
range, but I'm not sure which to use. I don't want it to be 200
tho, as the request was not "OK
".
Any ideas and tips on this subject?