I try to do
func f(w http.ResponseWriter, r *http.Request){
var userList = []string{ "Alice","Bob","Tom",}
buffer:=new(bytes.Buffer)
template.UserList(userList,buffer)
w.Write(buffer.Bytes())
}
func main(){
r := mux.NewRouter()
r.HandleFunc("/",f)
http.ListenAndServe(":8080",nil)
}
But in the browser the output is 404 page not found.
Using http.HandleFunc("/",f) it works.
Any suggestions?
I try to do func f(w http.ResponseWriter, r *http.Request){ var userList = []string{ "Alice","Bob","Tom",}
buffer:=new(bytes.Buffer) template.UserList(userList,buffer) w.Write(buffer.Bytes()) } func main(){ r := mux.NewRouter() r.HandleFunc("/",f) http.ListenAndServe(":8080",nil) } But in the browser the output is 404 page not found. Using http.HandleFunc("/",f) it works. Any suggestions?