httptransfer

package
v0.0.0-...-e14c0b9 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// common
	ErrorInvalidArgument   = ErrorCode{Code: 100000, Msg: "输入参数错误"}
	ErrorFrequentOperation = ErrorCode{Code: 100001, Msg: "频繁操作,稍后重试"}
	ErrorTryLater          = ErrorCode{Code: 100002, Msg: "请稍后重试"}

	// login
	ErrorLoginForbid = ErrorCode{Code: 101000, Msg: "账号禁止登陆,请联系我们"}

	// gold
	ErrorGoldInsufficient     = ErrorCode{Code: 102000, Msg: "能量不足,去攒能量吧!"}
	ErrorGoldShareFriendLimit = ErrorCode{Code: 102001, Msg: "分享超过限制,明天再来试试!"}
	ErrorCreditInsufficient   = ErrorCode{Code: 102002, Msg: "积分不足,去充值吧!"}
)
View Source
var UIdCtxKey = "uid"

Functions

func ErrJSONResp

func ErrJSONResp(c *gin.Context, httpCode int, err error)

func FilterParser

func FilterParser(ctx context.Context, f string, filterPointer interface{}) error

func GetUid

func GetUid(c *gin.Context) int64

func NotStrictAuthorizationMiddleware

func NotStrictAuthorizationMiddleware(secretKey string) gin.HandlerFunc

func ParseAdminQuery

func ParseAdminQuery(c *gin.Context, params *model.AdminListReq) error

func ParseBody

func ParseBody(c *gin.Context, reqPointer interface{}) error

func ParseQuery

func ParseQuery(c *gin.Context, reqPointer interface{}) error

func RangeParser

func RangeParser(ctx context.Context, r string) (int, int, error)

func RequestIdMiddleware

func RequestIdMiddleware(opts ...Option) gin.HandlerFunc

func SetContentRangeHeader

func SetContentRangeHeader(c *gin.Context, offset, respLen, total int)

func SortParser

func SortParser(ctx context.Context, sort string) (string, error)

func StrictAuthorizationMiddleware

func StrictAuthorizationMiddleware(secretKey string) gin.HandlerFunc

func SuccJSONResp

func SuccJSONResp(c *gin.Context, data interface{})

Types

type ErrorCode

type ErrorCode struct {
	Code int    `json:"code"`
	Msg  string `json:"msg"`
}

func (ErrorCode) Error

func (err ErrorCode) Error() string

func (ErrorCode) HasError

func (err ErrorCode) HasError() bool

type Handler

type Handler func(c *gin.Context, requestID string)

type JsonResponse

type JsonResponse struct {
	Code int         `json:"code"`
	Msg  string      `json:"msg"`
	Data interface{} `json:"data"`
}

type Option

type Option func(*config)

func WithHandler

func WithHandler(handler Handler) Option

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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