Best way to integrate huma with gin router and middleware #450
-
I have a server implemented with gin. The routes look something like this:
There are many router groups and many middlewares, all implemented from gin.RouterGroup and gin.HandlerFunc. My question is how to integrate huma without rewriting all middleware into huma middleware. If I create a single huma api from the root, how do I use my existing gin middlewares with this huma api instance? If I create multiple huma api instances under each router group using It would make sense if huma api instance can be created from another api instance like gin's router group but this doesn't seem possible. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
@tp-105 this isn't currently possible as Huma doesn't support multiple route groups on a single API instance. One workaround I've seen a few people do is wrap your middleware in another which checks the incoming path and only applies whatever middleware you need based on that path. Another option is to convert to Huma middleware and use it with |
Beta Was this translation helpful? Give feedback.
@tp-105 this isn't currently possible as Huma doesn't support multiple route groups on a single API instance. One workaround I've seen a few people do is wrap your middleware in another which checks the incoming path and only applies whatever middleware you need based on that path. Another option is to convert to Huma middleware and use it with
huma.Register
.