Merge pull request #500 from xianlubird/master

修改关于REST的一些问题
This commit is contained in:
astaxie
2015-07-29 07:33:15 +08:00

View File

@@ -89,17 +89,16 @@ Go没有为REST提供直接支持但是因为RESTful是基于HTTP协议实现
} }
func adduser(w http.ResponseWriter, r *http.Request) { func adduser(w http.ResponseWriter, r *http.Request) {
params := r.URL.Query() uid := r.FormValue("uid")
uid := params.Get(":uid")
fmt.Fprint(w, "you are add user %s", uid) fmt.Fprint(w, "you are add user %s", uid)
} }
func main() { func main() {
mux := routes.New() mux := routes.New()
mux.Get("/user/:uid", getuser) mux.Get("/user/:uid", getuser)
mux.Post("/user/:uid", modifyuser) mux.Post("/user/", adduser)
mux.Del("/user/:uid", deleteuser) mux.Del("/user/:uid", deleteuser)
mux.Put("/user/", adduser) mux.Put("/user/:uid", modifyuser)
http.Handle("/", mux) http.Handle("/", mux)
http.ListenAndServe(":8088", nil) http.ListenAndServe(":8088", nil)
} }