You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is it possible to plug in another router, such as gorilla mux, with Gin?
I am trying to add certain REST endpoints, but this router does not allow them. I'm at the point now where I've (unfortunately) coupled the router and it's grouping mechanisms tightly to my app, so migrating to a new router will be a tedious process.
I really like the way gin with it's versioning and middleware and so on; it is perfect for my use cases. It just has one problem which is the lack of ability to use standard REST endpoints. Having to do really ugly things with query params to solve this problem.
The problem is, I sometimes need endpoints like /items/username/:username, /items/:id/foo, /items/:slug/bar and so on all at the same time, but this router does not allow mixing those endpoints together because of the ambiguity. It can't differentiate the three obviously different paths.
How could I swap out the authorized.GET with a mux router.Get? Anyone have a solution to this?:
I don't see the point of swapping out Gin's router, then there isn't much of Gin left. You might as well use Chi, which has some nice ways to mount nested routers and then you don't need Gorilla Mux at all. Or if you really must use Gorilla Mux, then Negroni might be a better fit as that framework is all about bring your own router.
@robvdl Thanks for the suggestion, I actually just started refactoring to use Chi a couple hours ago. Works exactly how I need with the proper REST endpoints, and supports same style of middleware/grouping as Gin.
The reason I wanted to swap out is I wanted to keep the Gin and middleware/grouping, while using another routers path matcher with the GET, POST, etc. methods.
Is it possible to plug in another router, such as gorilla mux, with Gin?
I am trying to add certain REST endpoints, but this router does not allow them. I'm at the point now where I've (unfortunately) coupled the router and it's grouping mechanisms tightly to my app, so migrating to a new router will be a tedious process.
I really like the way gin with it's versioning and middleware and so on; it is perfect for my use cases. It just has one problem which is the lack of ability to use standard REST endpoints. Having to do really ugly things with query params to solve this problem.
The problem is, I sometimes need endpoints like
/items/username/:username
,/items/:id/foo
,/items/:slug/bar
and so on all at the same time, but this router does not allow mixing those endpoints together because of the ambiguity. It can't differentiate the three obviously different paths.How could I swap out the
authorized.GET
with a muxrouter.Get
? Anyone have a solution to this?:The text was updated successfully, but these errors were encountered: