Which one of the following is more correct if I want to make sure Recovery is always run at the end?
From the way I understand the docs + other issues, it feels like global middleware is run as a priority BEFORE group level middleware.
Thank you for the help!
Global Recovery
r := gin.New()
r.Use(GetLoggerMiddleware())
r.Use(gin.Recovery())
groupAuthed := r.Group("", GetAuthMiddleware())
groupPublic := r.Group("")
Group Level Recovery
r := gin.New()
r.Use(GetLoggerMiddleware())
groupAuthed := r.Group("", GetAuthMiddleware(), gin.Recovery())
groupPublic := r.Group("", gin.Recovery())
Comment From: Sivaram151
Hi @jimydavis , If you want make sure regarding recovery middleware always runs at the end, You can use the first approach (gin. Recovery() as the Global middleware of your router) I think this is the only way to handle any panic across the routers
Hope this is okay :)