http - golang mux HandleFunc always 404 -
i try handle http request using mux instead of standart handlefunc net/http, because of reasons. http used work, mux doesnt.
import ( _ "github.com/go-sql-driver/mysql" "github.com/gorilla/mux" _ "io/ioutil" "net/http" ) func init() { mx := mux.newrouter() //create poll mx.handlefunc("/poll", pollcreate) mx.handlefunc("/poll/{id}", loadpoll) mx.handlefunc("/poll/vote", castvote) http.listenandserve(":8080", mx) }
the following post request
localhost:8080/poll
results in:
info 2015-06-02 16:23:12,219 module.py:718] default: "post /poll http/1.1" 404 19
found solution.
change
http.listenandserve(":8080", mx)
to
http.handle("/", mx)
Comments
Post a Comment