Documentation ¶
Index ¶
- func AbortWithError(ctx *gin.Context, err BusinessError)
- func Alias(ctx *gin.Context) string
- func AliasForRecordMetrics(path string) gin.HandlerFunc
- func GetUmsUserInfo(ctx stdctx.Context) proposal.UmsUserInfo
- func SessionUserInfo(ctx stdctx.Context) proposal.SessionUserInfo
- func SetAlias(ctx *gin.Context, path string)
- func SetSessionUserInfo(ctx *gin.Context, info proposal.SessionUserInfo)
- func SetUmsUserInfo(ctx *gin.Context, info proposal.UmsUserInfo)
- func TraceID(ctx *gin.Context) string
- type BusinessError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AbortWithError ¶
func AbortWithError(ctx *gin.Context, err BusinessError)
func AliasForRecordMetrics ¶
func AliasForRecordMetrics(path string) gin.HandlerFunc
AliasForRecordMetrics 对请求路径起个别名,用于记录指标。 如:Get /user/:username 这样的路径,因为 username 会有非常多的情况,这样记录指标非常不友好。
func GetUmsUserInfo ¶
func GetUmsUserInfo(ctx stdctx.Context) proposal.UmsUserInfo
func SessionUserInfo ¶
func SessionUserInfo(ctx stdctx.Context) proposal.SessionUserInfo
func SetSessionUserInfo ¶
func SetSessionUserInfo(ctx *gin.Context, info proposal.SessionUserInfo)
func SetUmsUserInfo ¶
func SetUmsUserInfo(ctx *gin.Context, info proposal.UmsUserInfo)
Types ¶
type BusinessError ¶
type BusinessError interface { // WithError 设置错误信息 WithError(err error) BusinessError // WithAlert 设置告警通知 WithAlert() BusinessError // BusinessCode 获取业务码 BusinessCode() int // HTTPCode 获取 HTTP 状态码 HTTPCode() int // Message 获取错误描述 Message() string // StackError 获取带堆栈的错误信息 StackError() error // IsAlert 是否开启告警通知 IsAlert() bool // contains filtered or unexported methods }
func AbortError ¶
func AbortError(ctx *gin.Context) BusinessError
func Error ¶
func Error(httpCode, businessCode int, message string) BusinessError
Click to show internal directories.
Click to hide internal directories.