Skip to content
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

是否有办法在前置的全局中间件中获取到理论的路由? #2217

Closed
WankkoRee opened this issue Oct 17, 2022 · 0 comments
Closed

Comments

@WankkoRee
Copy link
Contributor

1. What version of Go and system type/arch are you using?

go version go1.18.4 windows/amd64

2. What version of GoFrame are you using?

v2.1.4

3. Can this issue be re-produced with the latest release?

yes

4. What did you do?

我注册了一个前置的全局中间件以实现ACL:

g.Server().Use(func(req *ghttp.Request) {
	if req. ... { // 此处进行权限判断
		req.Response.ClearBuffer()
		req.Response.WriteStatusExit(403, nil)
	}
	req.Middleware.Next()
	...
})

现在需要有一部分路由可以匿名访问,但我无法在上面代码中的权限判断时获取到req.Middleware.Next()后的理论路由,现在在全局中间件中的req.Router只能获取到全局中间件的路由。

但是在调试时发现未导出的req.handlers中已经可以取到我注册的动态路由,如通过判断req.handlers[...].Handler.Name是否存在预期的可匿名访问的路由来决定是否放行。

5. What did you expect to see?

能否开放相关接口获取到理论状态下的路由情况。

6. What did you see instead?

@WankkoRee WankkoRee changed the title 是否有办法在全局中间件的前置中获取到理论的路由? 是否有办法在前置的全局中间件中获取到理论的路由? Oct 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant