Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultWithLogger ¶
DefaultWithLogger create a gin engine with log middleware.
func ErrorWrapper ¶
func ErrorWrapper(h Handler) gin.HandlerFunc
ErrorWrapper can convert our Handler to gin.HandlerFunc with our error handler.
func LoggerMw ¶
func LoggerMw(logger *log.Logger) gin.HandlerFunc
LoggerMw create a gin request log middleware.
func ReplyError ¶
ReplyError handle multi error 1. BizError, return status: BizError.Status and BizError as json body 2. ValidationErrors, return status: 400, and json error body 3. other, return status 500 and json error body.
Types ¶
type BizError ¶
type BizError struct { Status int `json:"-"` Code int `json:"code"` Message string `json:"message,omitempty"` Err error `json:"-"` }
BizError is our custom error type.
func NewBizError ¶
NewBizError create new BizError.
func NewFromError ¶
NewFromError can create BizError from error.
Click to show internal directories.
Click to hide internal directories.