make it more readable
This commit is contained in:
parent
67667dd2ce
commit
3ed309536a
@ -25,7 +25,7 @@ func main() {
|
||||
|
||||
// let's add a route
|
||||
r.Get("/hello", func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Write([]byte("hello1"))
|
||||
w.Write([]byte("i am route /hello"))
|
||||
})
|
||||
// r.Post(pattern string, h http.HandlerFunc)
|
||||
// r.Put(pattern string, h http.HandlerFunc)
|
||||
@ -34,8 +34,8 @@ func main() {
|
||||
// you can inline middleware(s) to a route
|
||||
r.
|
||||
With(mwInline).
|
||||
Get("/test", func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Write([]byte("middle ware 3 test"))
|
||||
Get("/hello-2", func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Write([]byte("i am route /hello-2 with my own middleware"))
|
||||
})
|
||||
|
||||
// you define a resource
|
||||
@ -50,18 +50,18 @@ func main() {
|
||||
// PATCH /photos/:id
|
||||
// DELETE /photos/:id
|
||||
resource.Index(func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Write([]byte("user index"))
|
||||
w.Write([]byte("all photos"))
|
||||
})
|
||||
|
||||
resource.New(func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Write([]byte("create new user"))
|
||||
w.Write([]byte("upload a new pohoto"))
|
||||
})
|
||||
})
|
||||
|
||||
r.Group(func(grp *mux.Router) {
|
||||
grp.Use(mwGroup)
|
||||
grp.Get("/group", func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Write([]byte("i am group 1"))
|
||||
w.Write([]byte("i am route /group"))
|
||||
})
|
||||
})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user