package response import ( "github.com/gin-gonic/gin" ) type ( HandlerFunc = func(c *gin.Context) (Response, error) Middleware = func(HandlerFunc) HandlerFunc responseKey struct{} ) func Handler(f HandlerFunc) gin.HandlerFunc { return func(c *gin.Context) { res, err := f(c) if err != nil { c.Error(err) c.Abort() } else if res != nil { c.Set(responseKey{}, res) c.Abort() } } }