-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
frame/g 请问怎么拦截静态文件呢 #4167
Comments
What do you want to ask?Global Middleware is written in the tutorial. "Global middleware is only valid for dynamic request interception, and cannot intercept static file requests." I have a special need now, which is to have no access to anything without logging in. How to operate such as static files |
@weaweawe01 可以尝试hook,示例如下 s.BindHookHandlerByMap("/static/*", map[ghttp.HookName]ghttp.HandlerFunc{
ghttp.HookBeforeServe: func(r *ghttp.Request) { fmt.Println(ghttp.HookBeforeServe) },
ghttp.HookAfterServe: func(r *ghttp.Request) { fmt.Println(ghttp.HookAfterServe) },
ghttp.HookBeforeOutput: func(r *ghttp.Request) { fmt.Println(ghttp.HookBeforeOutput) },
ghttp.HookAfterOutput: func(r *ghttp.Request) { fmt.Println(ghttp.HookAfterOutput) },
}) |
搞定 |
Get it done |
What do you want to ask?
全局中间件 中教程中有写到。 “全局中间件仅对动态请求拦截有效,无法拦截静态文件请求。”
我现在有个特殊的需求就是 需要在没有登录的情况下什么都访问不了。包括静态文件这种的怎么 操作呢
The text was updated successfully, but these errors were encountered: