#2 希望可以支持为Group设置中间件

Closed
opened 5 years ago by lunny · 3 comments
lunny commented 5 years ago

Author: @Shuenhoy

Author: @Shuenhoy
lunny commented 5 years ago
Owner

Author: @lunny

其实只要在中间件中匹配Group的前缀就可以了。

Author: @lunny 其实只要在中间件中匹配Group的前缀就可以了。
lunny commented 5 years ago
Owner

Author: @lunny

不知道有没有解决你的问题?@Shuenhoy

Author: @lunny 不知道有没有解决你的问题?@Shuenhoy
lunny commented 5 years ago
Owner

Author: @lunny

Now, you can use the below code to add a middleware to a group. All the handlers could be add to group.

o := tango.Classic()
o.Group("/api", func(g *Group) {
        g.Use(HandlerFunc(func (ctx *Context) {
            fmt.Println("this is a group middleware")
            ctx.Next()
        }))
        g.Get("/1", func() string {
            return "/1"
        })
    })
Author: @lunny Now, you can use the below code to add a middleware to a group. All the handlers could be add to group. ``` o := tango.Classic() o.Group("/api", func(g *Group) { g.Use(HandlerFunc(func (ctx *Context) { fmt.Println("this is a group middleware") ctx.Next() })) g.Get("/1", func() string { return "/1" }) }) ```
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Due Date

No due date set.

Dependencies

This issue currently doesn't have any dependencies.

Loading…
Cancel
Save
There is no content yet.