core

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 17, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AbortWithError

func AbortWithError(ctx *gin.Context, err BusinessError)

func Alias

func Alias(ctx *gin.Context) string

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 SetAlias

func SetAlias(ctx *gin.Context, path string)

func SetSessionUserInfo

func SetSessionUserInfo(ctx *gin.Context, info proposal.SessionUserInfo)

func SetUmsUserInfo

func SetUmsUserInfo(ctx *gin.Context, info proposal.UmsUserInfo)

func TraceID

func TraceID(ctx *gin.Context) string

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL