Documentation ¶
Index ¶
- func EchoHttpErrorHandler(server *echo.Echo) echo.HTTPErrorHandler
- func HttpErrorHandleMiddleware() echo.MiddlewareFunc
- func IsHTTPError(e interface{}) bool
- func Middleware() gin.HandlerFunc
- type HTTPError
- func BadRequest(message string, code int64) *HTTPError
- func InternalError(message string, code int64) *HTTPError
- func New(statusCode int, message string, code int64) *HTTPError
- func Parse(e error, code int64) *HTTPError
- func RequestNotAccept(message string, code int64) *HTTPError
- func TryConstructHttpError(err interface{}) (*HTTPError, bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EchoHttpErrorHandler ¶
func EchoHttpErrorHandler(server *echo.Echo) echo.HTTPErrorHandler
EchoHttpErrorHandler echo httpErrorhandler 兼容 自定义 httperror
func HttpErrorHandleMiddleware ¶
func HttpErrorHandleMiddleware() echo.MiddlewareFunc
HttpErrorHandleMiddleware 错误处理
Types ¶
type HTTPError ¶
type HTTPError struct { // Http 状态码 StatusCode int `json:"http_code"` // 错误消息 Message string `json:"msg"` // 业务错误码 Code int64 `json:"code"` // IsHttpError 标记 IsHTTPError bool `json:"-"` // contains filtered or unexported fields }
HTTPError 自定义HTTP 错误
func InternalError ¶
InternalError 500 系统内部错误
func RequestNotAccept ¶
RequestNotAccept 406 请求不可接受
func TryConstructHttpError ¶
TryConstructHttpError 尝试使用字符串或者httperror.HttpError 构建httperror
Click to show internal directories.
Click to hide internal directories.