gin-error-handler/handler.go
2024-01-17 23:17:21 -06:00

14 lines
257 B
Go

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)
}
}
}