Documentation ¶
Index ¶
- Constants
- func BadRequest(ctx *gin.Context, cause error, msgs ...string)
- func Error(ctx *gin.Context, err *HttpError)
- func JSON(ctx *gin.Context, data any, err *HttpError)
- func Log2Tsv(fp string, w io.Writer, times ...time.Time) (err error)
- func NewLogHandler[T any](logger *wrap.Logger, name string) gin.HandlerFunc
- func Ok(ctx *gin.Context)
- type HttpError
- func ErrBadRequest(cause error, opts ...Option) (err *HttpError)
- func ErrConflict(err error, msg string) (out *HttpError)
- func ErrInvalidParameter(err error, msg string) (out *HttpError)
- func ErrNotFound(err error) (out *HttpError)
- func ErrParseFailed(cause error) (err *HttpError)
- func ErrServerError(cause error, opts ...Option) (err *HttpError)
- func ErrUnauthorized(err error, msg string) (out *HttpError)
- func NewHttpError(cause error, httpCode, code int, opts ...Option) (err *HttpError)
- type Option
Constants ¶
View Source
const ( KeyRequestId = "_RequestId" KeyUserId = "_UserId" KeyUserRole = "UserRole" KEY_User = "User" KeyError = "error" KeyEvent = "event" )
Variables ¶
This section is empty.
Functions ¶
func NewLogHandler ¶
Types ¶
type HttpError ¶
type HttpError struct { Cause string `json:"cause"` HttpCode int `json:"httpCode"` Code int `json:"code"` Msg string `json:"msg"` // contains filtered or unexported fields }
func ErrBadRequest ¶
code ranges:
...=-100 has no right -99=-1 invalid request 0 ok 1..=99 business error 100... unexpected error
func ErrConflict ¶
func ErrInvalidParameter ¶
func ErrNotFound ¶
func ErrParseFailed ¶
func ErrServerError ¶
func ErrUnauthorized ¶
func NewHttpError ¶
Click to show internal directories.
Click to hide internal directories.