✨ Add HandlerWithError
This commit is contained in:
parent
371388838e
commit
447f3b38ef
4 changed files with 186 additions and 0 deletions
14
handler.go
Normal file
14
handler.go
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
package handler
|
||||
|
||||
import "github.com/gin-gonic/gin"
|
||||
|
||||
type HandlerWithError func(c *gin.Context) error
|
||||
|
||||
func HandlerWithErrorWrapper(h HandlerWithError) gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
err := h(c)
|
||||
if err != nil {
|
||||
c.Error(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue