Improve gin support (interface, error, middlewares) - #530
Conversation
Use gin.IRouter interface instead of *gin.Engine Switch custom middleware code to gin middleware Original changes: oapi-codegen#530
|
Hey, this is neat but it ended throwing off how we were constructing the gin engine, looks like now the pattern needs to be: // Register the business logic handlers
apiRoutes := api.RegisterHandlers(r, apiServer).(*gin.RouterGroup)
r.Use(apiRoutes.Handlers...)Instead of what was previously: // Register the business logic handlers
r := api.RegisterHandlers(r, apiServer)I'm gonna submit a MR to update the Gin example since this new patch breaks the example. |
|
returning concrete types should be preferred over returning interfaces as concrete types that implement an interface may provide more functionality than the interface. |
|
huh, yeah. Agreed, returning concrete types is better. I missed that. I wonder whether to roll back this change. I hate breaking existing code like this. |
|
We could update it to return a |
The most recent release of `oapi-codegen` (v1.10.0) included changes that broke the existing examples which were introduced in oapi-codegen#530 This change updates the `gin` example by regening the code-generated files and updating the router registration to work with the new generated code.
|
release a new minor version and retract the last one maybe in go.mod? |
This reverts commit 11622c2. It caused a breaking change to existing users.
The most recent release of `oapi-codegen` (v1.10.0) included changes that broke the existing examples which were introduced in #530 This change updates the `gin` example by regening the code-generated files and updating the router registration to work with the new generated code.
Co-authored-by: Zihao Zhang <z@zeet.co>
This reverts commit f10cd14. It caused a breaking change to existing users.
The most recent release of `oapi-codegen` (v1.10.0) included changes that broke the existing examples which were introduced in oapi-codegen#530 This change updates the `gin` example by regening the code-generated files and updating the router registration to work with the new generated code.
Co-authored-by: Zihao Zhang <z@zeet.co>
This reverts commit 11622c2. It caused a breaking change to existing users.
The most recent release of `oapi-codegen` (v1.10.0) included changes that broke the existing examples which were introduced in oapi-codegen#530 This change updates the `gin` example by regening the code-generated files and updating the router registration to work with the new generated code.
this will allow us to support nested router mounting using engine/routergroup/other routers
fixes Support RouterGroup when registering handlers with gin #507
the custom middleware code doesn't support context abort or c.Next() in normal gin middleware, this also fixes gin: abort request in case middleware function called abort #494 gin: included middleware cannot abort request #485
huge fix for debugging authentication func. before this change the nested e.Errors[] is completely hidden not surfaced anywhere.