default options handler
This commit is contained in:
@@ -25,7 +25,7 @@ func main() {
|
||||
r.Use(middleware1, middleware2)
|
||||
|
||||
// let's add a route
|
||||
r.Get("/hello", func(w http.ResponseWriter, r *http.Request) {
|
||||
r.GET("/hello", func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Write([]byte("i am route /hello"))
|
||||
})
|
||||
// r.Post(pattern string, h http.HandlerFunc)
|
||||
@@ -35,7 +35,7 @@ func main() {
|
||||
// you can inline middleware(s) to a route
|
||||
r.
|
||||
With(mwInline).
|
||||
Get("/hello-2", func(w http.ResponseWriter, r *http.Request) {
|
||||
GET("/hello-2", func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Write([]byte("i am route /hello-2 with my own middleware"))
|
||||
})
|
||||
|
||||
@@ -62,13 +62,13 @@ func main() {
|
||||
// create a group of few routes with their own middlewares
|
||||
r.Group(func(grp *mux.Router) {
|
||||
grp.Use(mwGroup)
|
||||
grp.Get("/group", func(w http.ResponseWriter, r *http.Request) {
|
||||
grp.GET("/group", func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Write([]byte("i am route /group"))
|
||||
})
|
||||
})
|
||||
|
||||
// catches all
|
||||
r.Get("/", func(w http.ResponseWriter, r *http.Request) {
|
||||
r.GET("/", func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Write([]byte("hello there"))
|
||||
})
|
||||
|
||||
|
Reference in New Issue
Block a user