package api import ( "github.com/gin-gonic/gin" "github.com/gissleh/stufflog/internal/slerrors" ) func handler(key string, callback func(c *gin.Context) (interface{}, error)) gin.HandlerFunc { return func(c *gin.Context) { res, err := callback(c) if err != nil { slerrors.Respond(c, err) return } resJson := make(map[string]interface{}, 1) resJson[key] = res c.JSON(200, resJson) } }