Versions in this module Expand all Collapse all v1 v1.0.8 Dec 5, 2024 v1.0.7 Nov 21, 2024 v1.0.6 Nov 20, 2024 Changes in this version + func CacheControlMaxAge(millisecond int) gin.HandlerFunc + func EtagHandler() gin.HandlerFunc + type EtagWriter struct + func (w *EtagWriter) Unwrap() http.ResponseWriter + func (w *EtagWriter) Write(b []byte) (int, error) v1.0.5 Oct 24, 2024 v1.0.4 Oct 21, 2024 v1.0.3 Oct 20, 2024 v1.0.2 Oct 19, 2024 Changes in this version + func GetBaseURL(req *http.Request) string + type Event struct + Data []byte + Event string + ID string + type SSE struct + Headers map[string]string + func NewSSE(length int, timeout time.Duration) *SSE + func (s *SSE) Close() + func (s *SSE) Publish(v Event) + func (s *SSE) ServeHTTP(w http.ResponseWriter, _ *http.Request) type ScrollPager + Items []T v1.0.0 Oct 10, 2024 Changes in this version + var ErrAccountDisabled = NewError("ErrAccountDisabled", "登录限制") + var ErrAddNewDevice = NewError("ErrAddNewDevice", "请重新添加此设备") + var ErrBadRequest = NewError("ErrBadRequest", "请求参数有误") + var ErrCaptchaWrong = NewError("ErrCaptchaWrong", "验证码错误") + var ErrDB = NewError("ErrStore", "数据发生错误") + var ErrDevice = NewError("ErrDevice", "设备异常") + var ErrDeviceOffline = NewError("ErrDeviceOffline", "设备离线") + var ErrJSON = NewError("ErrUnmarshal", "JSON 编解码出错") + var ErrLoginLimiter = NewError("ErrLoginLimiter", "触发登录限制") + var ErrNameOrPasswd = NewError("ErrNameOrPasswd", "用户名或密码错误") + var ErrNotFound = NewError("ErrNotFound", "资源未找到") + var ErrPermissionDenied = NewError("ErrPermissionDenied", "没有该资源的权限") + var ErrServer = NewError("ErrServer", "服务器发生错误") + var ErrTimeout = NewError("ErrTimeout", "请求超时") + var ErrUnauthorizedToken = NewError("ErrUnauthorizedToken", "用户已过期或错误") + var ErrUnknown = NewError("UnKnow", "未知错误") + var ErrUsedLogic = NewError("ErrUsedLogic", "使用逻辑错误") + func AbortWithStatusJSON(c ResponseWriter, err error, fn ...WithData) + func AddHead() gin.HandlerFunc + func AuthLevel(level int) gin.HandlerFunc + func AuthMiddleware(secret string) gin.HandlerFunc + func Fail(c ResponseWriter, err error, fn ...WithData) + func GetGroupLevel(c *gin.Context) int8 + func GetRole(c *gin.Context) string + func GetUID(c *gin.Context) int + func GetUsername(c *gin.Context) string + func HanddleJSONErr(err error) error + func HandlerResponseMsg(resp http.Response) error + func IPRateLimiter(r rate.Limit, b int) func(ip string) bool + func IPRateLimiterForGin(r rate.Limit, b int) gin.HandlerFunc + func Limit(v, min, max int) int + func Logger(log *slog.Logger, recordBodyFn func(*gin.Context) bool) gin.HandlerFunc + func Mertics() gin.HandlerFunc + func Message(err error) string + func MustTraceID(ctx context.Context) string + func NewToken(input TokenInput) (string, error) + func Offset(page, size int) int + func RateLimiter(r rate.Limit, b int) gin.HandlerFunc + func RecordResponse() gin.HandlerFunc + func Recover() gin.HandlerFunc + func SendChunk(ch <-chan Chunk, c *gin.Context) + func SendChunkPro(ch <-chan Chunk, c *gin.Context) + func SendSSE(ch <-chan EventMessage, c *gin.Context) + func SetRelease() + func SetTraceID(ctx *gin.Context, id string) + func SetupMutexProfile(rate int) + func SetupPProf(r *gin.Engine, ips *[]string) + func Success(c HTTPContext, bean any) + func TraceID(ctx context.Context) (string, bool) + func WarpH[I any, O any](fn func(*gin.Context, *I) (O, error)) gin.HandlerFunc + type Chunk struct + Current int + Err string + Failure int + Success int + Total int + type Claims struct + GroupID int + GroupLevel int8 + Level int + Role string + UID int + Username string + func ParseToken(tokenString string, secret string) (*Claims, error) + type E struct + Details []string + Msg string + Reason string + func Unmarshal(b []byte) (e E) + func (e E) String() string + type Error struct + func NewError(reason, msg string) *Error + func (e *Error) Details() []string + func (e *Error) HTTPCode() int + func (e *Error) Map() map[string]any + func (e *Error) Message() string + func (e *Error) Msg(s string) *Error + func (e *Error) Reason() string + func (e *Error) With(args ...string) *Error + func (e *Error) Withf(format string, args ...any) *Error + func (e Error) Error() string + type Errorer interface + Details func() []string + HTTPCode func() int + Message func() string + Reason func() string + type EventMessage struct + func NewEventMessage(event string, data map[string]any) *EventMessage + type HTTPContext interface + Header func(key, value string) + JSON func(int, any) + type PageOutput struct + Items any + Total int64 + type PagerFilter struct + Page int + Size int + Sort string + SortSafelist []string + func (f PagerFilter) Limit() int + func (f PagerFilter) MustSortColumn() string + func (f PagerFilter) Offset() int + func (f PagerFilter) SortColumn() (string, error) + func (f PagerFilter) SortDirection() string + type ResponseMsg struct + Msg string + type ResponseWriter interface + AbortWithStatusJSON func(code int, obj interface{}) + File func(filepath string) + JSON func(code int, obj interface{}) + Set func(string, any) + type ResponseWriterWrapper struct + Body *bytes.Buffer + func (w ResponseWriterWrapper) Write(b []byte) (int, error) + func (w ResponseWriterWrapper) WriteString(s string) (int, error) + type ScrollPager struct + Data []T + Next string + type TokenInput struct + Exires time.Duration + GroupID int + GroupLevel int8 + Level int + Role string + Secret string + UID int + Username string + type Validator struct + Errors map[string]string + func NewValidator() *Validator + func (v *Validator) AddError(key, message string) *Validator + func (v *Validator) Check(ok bool, key, message string) *Validator + func (v *Validator) List() []string + func (v *Validator) Result() (bool, []string) + func (v *Validator) Valid() bool + type WithData func(map[string]any)