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。这个似乎不符合直觉。
http://localhost/
http://localhost/admin/
从这个代码来说,把 tango.Static 的 Prefix 设成/admin似乎也达成目的。但我这么做的初衷是希望给 http://localhost/admin/ 做中间件,特别地控制它的权限。
tango.Static
Prefix
/admin
Author: @lunny
目前确实不支持,全局中间件是无论如何都会执行的,但是Group中间件和Action中间件只有路由请求才会执行。
No due date set.
No dependencies set.
Deleting a branch is permanent. It CANNOT be undone. Continue?
Author: @qjebbs
假设有以下代码
运行后,无论访问
http://localhost/
还是http://localhost/admin/
都是404。这个似乎不符合直觉。从这个代码来说,把
tango.Static
的Prefix
设成/admin
似乎也达成目的。但我这么做的初衷是希望给http://localhost/admin/
做中间件,特别地控制它的权限。Author: @lunny
目前确实不支持,全局中间件是无论如何都会执行的,但是Group中间件和Action中间件只有路由请求才会执行。