I try to handle HTTP request using mux instead of standart HandleFunc from net/http, because of reasons. With http it used to work, with mux it doesnt.
import (
_ "github.com/go-sql-driver/mysql"
"github.com/gorilla/mux"
_ "io/ioutil"
"net/http"
)
func init() {
mx := mux.NewRouter()
//create a 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