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

怎么添加HandlerFunc #11

Open
wangcheng0509 opened this issue May 28, 2020 · 9 comments
Open

怎么添加HandlerFunc #11

wangcheng0509 opened this issue May 28, 2020 · 9 comments
Labels
good first issue Good for newcomers

Comments

@wangcheng0509
Copy link

怎么添加路由前的管道HandlerFunc?

@xxjwxc
Copy link
Owner

xxjwxc commented May 28, 2020

路有前? 这个框架主要帮助用户绑定对象。不用手动解析。不影响实际gin本身的框架逻辑。是gin框架的补充。

@wangcheng0509
Copy link
Author

image
怎么能让这个jwt中间件生效?

@wangcheng0509
Copy link
Author

wangcheng0509 commented May 28, 2020

r := gin.New()
apipath := r.Group("/api")
account := apipath.Group("/account")
account.Use(jwt.JWT())
{
base.Register(r, new(api.Account))
// account.GET("/profile", api.Profile)
// account.GET("/menu", api.Menu)
}

@xxjwxc
Copy link
Owner

xxjwxc commented May 28, 2020

r := gin.New()
apipath := r.Group("/api")
account := apipath.Group("/account")
account.Use(jwt.JWT())
{
base.Register(r, new(api.Account))
// account.GET("/profile", api.Profile)
// account.GET("/menu", api.Menu)
}

// ginrpc 
base := ginrpc.New()
// router := gin.Default()
base.Register(r, new(Hello)) // object register like(go-micro)
r.POST("/test6", base.HandlerFunc(TestFun6))                            // function register
base.RegisterHandlerFunc(r, []string{"post", "get"}, "/test", TestFun6) 
r.Run(":8080")

这样的吧?

ginrpc 主要监听:gin.Engine

@xxjwxc
Copy link
Owner

xxjwxc commented May 28, 2020

这个问题似乎存在。我这两天更新一下。

@wangcheng0509
Copy link
Author

image
好的,辛苦,我看了你的源码,应该是没兼容gin的middleware,而想要使用middleware又需要重新注册路由

@xxjwxc xxjwxc added the good first issue Good for newcomers label May 28, 2020
@xxjwxc
Copy link
Owner

xxjwxc commented May 28, 2020

是的,我会非常迅速加进去的。感谢使用及提问

@xxjwxc
Copy link
Owner

xxjwxc commented May 28, 2020

看了下应该很好解决:需要将ginrpc里面的 *gin.Engine 定义改成 gin.IRouter 定义就可以兼容两者了

@xxjwxc
Copy link
Owner

xxjwxc commented May 28, 2020

代码已更新

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants