tango Group 与 Static 配合使用的问题 #34

Open
opened 2016-08-19 09:14:04 +00:00 by lunny · 1 comment
Owner

Author: @qjebbs

假设有以下代码

t := tango.Classic()
g := tango.NewGroup()
g.Use(tango.Static(tango.StaticOptions{
    RootPath:   "./admin",
    Prefix:     "/",
    IndexFiles: []string{"index.html"},
}))
t.Group("/admin", g)
t.Run(":80")

运行后,无论访问http://localhost/还是http://localhost/admin/都是404。这个似乎不符合直觉。

从这个代码来说,把 tango.StaticPrefix 设成/admin似乎也达成目的。但我这么做的初衷是希望给 http://localhost/admin/ 做中间件,特别地控制它的权限。

Author: @qjebbs 假设有以下代码 ``` t := tango.Classic() g := tango.NewGroup() g.Use(tango.Static(tango.StaticOptions{ RootPath: "./admin", Prefix: "/", IndexFiles: []string{"index.html"}, })) t.Group("/admin", g) t.Run(":80") ``` 运行后,无论访问`http://localhost/`还是`http://localhost/admin/`都是404。这个似乎不符合直觉。 从这个代码来说,把 `tango.Static` 的 `Prefix` 设成`/admin`似乎也达成目的。但我这么做的初衷是希望给 `http://localhost/admin/` 做中间件,特别地控制它的权限。
Author
Owner

Author: @lunny

目前确实不支持,全局中间件是无论如何都会执行的,但是Group中间件和Action中间件只有路由请求才会执行。

Author: @lunny 目前确实不支持,全局中间件是无论如何都会执行的,但是Group中间件和Action中间件只有路由请求才会执行。
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: lunny/tango#34
No description provided.