shiyanhui / hero

A handy, fast and powerful go template engine.
https://shiyanhui.github.io/hero
Other
1.57k stars 96 forks source link

Problem with gorilla mux #48

Closed HVCode closed 6 years ago

HVCode commented 6 years ago

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?

HVCode commented 6 years ago

I already solved it, I just had to pass r as a parameter http.ListenAndServe(...,r)