httpx

package
v0.0.15 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2025 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AllowMethods = "GET, POST, PUT, DELETE, OPTIONS"
	AllowHeaders = "" +
		"Origin, " +
		"Content-Type, " +
		"Content-Length, " +
		"Accept-Encoding, " +
		"X-CSRF-Token, " +
		"Authorization, "
)

Variables

This section is empty.

Functions

func CORS

func CORS() gin.HandlerFunc

func DebouceAw

func DebouceAw(path ...string)

func Debounce

func Debounce(duration time.Duration) gin.HandlerFunc

func DebounceDisable

func DebounceDisable()

func DumpRouters

func DumpRouters(call func(info gin.RouteInfo))

func Fail

func Fail(ctx *gin.Context, err *errors.Error)

func Get

func Get(baseURL string, params map[string]string) (resp string, err *errors.Error)

func GetByCtx

func GetByCtx(ctx *gin.Context, baseURL string, params map[string]interface{}) (map[string]interface{}, *errors.Error)

func GetClientIP

func GetClientIP(ctx *gin.Context) string

func GetHeader

func GetHeader(baseURL string, params map[string]string, header map[string]string) (resp string, err *errors.Error)

func GetMap

func GetMap(baseURL string, params map[string]string) (map[string]interface{}, *errors.Error)

func GetMapHeader

func GetMapHeader(baseURL string, params map[string]string, header map[string]string) (map[string]interface{}, *errors.Error)

func GetToken

func GetToken(c *gin.Context) string

func GetTokenByCtx

func GetTokenByCtx(c *gin.Context, mustExit bool) string

GetTokenByCtx

func GetTraceID

func GetTraceID(ctx *gin.Context) string

func GetUserID

func GetUserID(ctx *gin.Context) string

func GetUserIDByToken

func GetUserIDByToken(token string) (userID string)

func GetUserIDInt

func GetUserIDInt(ctx *gin.Context) int

func GetUserIDInt64

func GetUserIDInt64(ctx *gin.Context) int64

func GetUserInfo

func GetUserInfo(ctx *gin.Context) map[string]interface{}

func GetUserInfoValue

func GetUserInfoValue(ctx *gin.Context, key string) any

func Logger

func Logger() gin.HandlerFunc

func NewCtx

func NewCtx() *gin.Context

func ParseJSON

func ParseJSON(jsonStr string) map[string]interface{}

func ParseXML

func ParseXML[T any](xmlStr string) (*T, *errors.Error)

func PostForm

func PostForm(baseURL string, params map[string]string) (resp string, err *errors.Error)

func PostJSON

func PostJSON(baseURL string, params interface{}) (map[string]interface{}, *errors.Error)

func PostJSONByCtx

func PostJSONByCtx(ctx *gin.Context, baseURL string, params interface{}) (map[string]interface{}, *errors.Error)

func PostJSONHeader

func PostJSONHeader(baseURL string, params interface{}, header map[string]string) (map[string]interface{}, *errors.Error)

func PostJSONResp

func PostJSONResp(baseURL string, params interface{}) (resp string, err *errors.Error)

func PostJSONRespHeader

func PostJSONRespHeader(baseURL string, params interface{}, header map[string]string) (resp string, err *errors.Error)

func PostXML

func PostXML(baseURL string, params map[string]string) (resp string, err *errors.Error)

func RegisterRouter

func RegisterRouter(reg func(groupRouter *gin.RouterGroup))

RegisterRouter 注册路由

func RegisterRouterMid

func RegisterRouterMid(group func(groupRouter *gin.RouterGroup, mid ...gin.HandlerFunc) *gin.RouterGroup, mid ...gin.HandlerFunc) *gin.RouterGroup

func SetTraceID

func SetTraceID(ctx *gin.Context)

func SetUserID

func SetUserID(ctx *gin.Context, userID string)

func SetUserInfo

func SetUserInfo(ctx *gin.Context, userInfo map[string]interface{})

func Shutdown

func Shutdown(code string, ctx context.Context) error

func SignDef

func SignDef() gin.HandlerFunc

校验token

func SignRedis

func SignRedis() gin.HandlerFunc

func SignUserDef

func SignUserDef(userFilter map[string]interface{}) gin.HandlerFunc

SignUserDef 校验token并校验用户 map用于校验用户信息是否符合要求

func SignUserRedis

func SignUserRedis(userFilter map[string]interface{}) gin.HandlerFunc

func Startup

func Startup(code, port string) error

func Success

func Success(ctx *gin.Context, data any)

Types

type HeaderParams

type HeaderParams struct {
	Authorization string `header:"Authorization" binding:"required,min=20"`
}

type ShardedRequestMap

type ShardedRequestMap struct {
	// contains filtered or unexported fields
}

func NewShardedRequestMap

func NewShardedRequestMap() *ShardedRequestMap

func (*ShardedRequestMap) Get

func (srm *ShardedRequestMap) Get(key string) (time.Time, bool)

func (*ShardedRequestMap) Set

func (srm *ShardedRequestMap) Set(key string, value time.Time)

Jump to

Keyboard shortcuts

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