Documentation
¶
Index ¶
- Variables
- func GetUriPath(uri string) (string, error)
- func InitGinPlus(customHeaderPrefix string)
- func InitSign(signHeaders []string, signHeaderPrefix string)
- func IsEncoded(str string) bool
- func Sign(uri string, args map[string][]string, headers map[string][]string, body []byte, ...) (signature string, signStr string)
- func SignCheck(c *gin.Context)
- func SignEx(uri string, args map[string][]string, headers map[string][]string, body []byte, ...) (signature string, signStr string)
- func SignSimple(uri string, args map[string]string, headers map[string]string, body []byte, ...) (signature string, signStr string)
- func URI_ENCODE(uri string) string
- type APISignConfig
- type ContextPlus
- func (c *ContextPlus) CustomHeaderName(headerName string) (customHeaderName string)
- func (c *ContextPlus) GetBody() (body []byte, err error)
- func (c *ContextPlus) GetClientMetaInfo() (platform, version, channel, deviceID string)
- func (c *ContextPlus) GetCustomHeader(key string) string
- func (c *ContextPlus) GetCustomHeaderInt(key string, def int) (value int)
- func (c *ContextPlus) GetCustomHeaderInt64(key string, def int64) (value int64)
- func (c *ContextPlus) GetURI() string
- func (c *ContextPlus) JsonFail(reason string) gin.H
- func (c *ContextPlus) JsonFailWithMsg(reason string, errmsg interface{}) gin.H
- func (c *ContextPlus) JsonOk(data interface{}) gin.H
- func (c *ContextPlus) JsonOk2(reason string, data interface{}) gin.H
- func (c *ContextPlus) MustGetCustomHeader(key string) string
- func (c *ContextPlus) MustGetCustomHeaderInt(key string, def int) (value int)
- func (c *ContextPlus) MustGetCustomHeaderInt64(key string, def int64) (value int64)
- func (c *ContextPlus) MustGetUserID() (userID int64, userType int32)
- func (c *ContextPlus) MustQuery(key string) (value string)
- func (c *ContextPlus) MustQueryInt32(key string) (value int32)
- func (c *ContextPlus) MustQueryInt64(key string) (value int64)
- func (c *ContextPlus) ParseQueryJSONObject(query interface{})
- func (c *ContextPlus) QueryBool(key string) (b bool)
- func (c *ContextPlus) QueryBoolPtr(key string) (b *bool)
- func (c *ContextPlus) QueryInt32(key string, def int32) (value int32)
- func (c *ContextPlus) QueryInt64(key string, def int64) (value int64)
- type HexHashFunc
Constants ¶
This section is empty.
Variables ¶
var EMPTY_BODY []byte = []byte("")
Functions ¶
func GetUriPath ¶
func SignSimple ¶
func URI_ENCODE ¶
Types ¶
type APISignConfig ¶
type APISignConfig struct { Debug bool CheckSign bool DebugSignKey string AppKeys map[string]string SignUrls map[string]bool }
var SignConfig APISignConfig = APISignConfig{false, true, "", make(map[string]string), make(map[string]bool)}
SignConfig global signature configuration
func (*APISignConfig) GetSignKey ¶
func (a *APISignConfig) GetSignKey(appID string) string
GetSignKey get signature key by appID
type ContextPlus ¶
ContextPlus 扩展的上下文.
func NewContetPlus ¶
func NewContetPlus(c *gin.Context) (context *ContextPlus)
NewContetPlus 创建一个扩展上下文.
func (*ContextPlus) CustomHeaderName ¶
func (c *ContextPlus) CustomHeaderName(headerName string) (customHeaderName string)
CustomHeaderName 获取自定义的请求头名.
func (*ContextPlus) GetBody ¶
func (c *ContextPlus) GetBody() (body []byte, err error)
GetBody 获取body内容, 多次调用时, 会使用缓存.
func (*ContextPlus) GetClientMetaInfo ¶
func (c *ContextPlus) GetClientMetaInfo() (platform, version, channel, deviceID string)
GetClientMetaInfo 获取请求头中的Platform,Version, Channel, deviceID 相关信息.
func (*ContextPlus) GetCustomHeader ¶
func (c *ContextPlus) GetCustomHeader(key string) string
GetCustomHeader 获取自定义的请求头(请求头名称会自动添加配置的customHeaderPrefix)
func (*ContextPlus) GetCustomHeaderInt ¶
func (c *ContextPlus) GetCustomHeaderInt(key string, def int) (value int)
GetCustomHeaderInt 获取一个int请求头值
func (*ContextPlus) GetCustomHeaderInt64 ¶
func (c *ContextPlus) GetCustomHeaderInt64(key string, def int64) (value int64)
GetCustomHeaderInt64 获取一个int请求头值
func (*ContextPlus) JsonFail ¶
func (c *ContextPlus) JsonFail(reason string) gin.H
JsonFail 返回失败及reason节点
func (*ContextPlus) JsonFailWithMsg ¶
func (c *ContextPlus) JsonFailWithMsg(reason string, errmsg interface{}) gin.H
JsonFailWithMsg 返回失败及reason,errmsg节点
func (*ContextPlus) JsonOk ¶
func (c *ContextPlus) JsonOk(data interface{}) gin.H
JsonOk 返回成功及data节点
func (*ContextPlus) JsonOk2 ¶
func (c *ContextPlus) JsonOk2(reason string, data interface{}) gin.H
JsonOk 返回成功及reason, data节点
func (*ContextPlus) MustGetCustomHeader ¶
func (c *ContextPlus) MustGetCustomHeader(key string) string
MustGetCustomHeader 获取自定义请求头, 如果获取失败, 抛出异常.
func (*ContextPlus) MustGetCustomHeaderInt ¶
func (c *ContextPlus) MustGetCustomHeaderInt(key string, def int) (value int)
MustGetCustomHeaderInt 获取一个int请求头值
func (*ContextPlus) MustGetCustomHeaderInt64 ¶
func (c *ContextPlus) MustGetCustomHeaderInt64(key string, def int64) (value int64)
MustGetCustomHeaderInt64 获取一个int请求头值
func (*ContextPlus) MustGetUserID ¶
func (c *ContextPlus) MustGetUserID() (userID int64, userType int32)
MustGetUserID 获取用户ID,用户类型.
func (*ContextPlus) MustQuery ¶
func (c *ContextPlus) MustQuery(key string) (value string)
MustQuery 获取Get参数, 如果为空,抛出ErrArgsMissing错误.
func (*ContextPlus) MustQueryInt32 ¶
func (c *ContextPlus) MustQueryInt32(key string) (value int32)
MustQueryInt32 获取int32值. 如果出错,抛出ErrArgsInvalid错误.
func (*ContextPlus) MustQueryInt64 ¶
func (c *ContextPlus) MustQueryInt64(key string) (value int64)
MustQueryInt64 获取int64值. 如果出错,抛出ErrArgsInvalid错误.
func (*ContextPlus) ParseQueryJSONObject ¶
func (c *ContextPlus) ParseQueryJSONObject(query interface{})
ParseQueryJSONObject 解析请求体.
func (*ContextPlus) QueryBool ¶
func (c *ContextPlus) QueryBool(key string) (b bool)
QueryBool 获取bool值, 其中"",true, yes, on, y, t 都表示真, 其它值都表示假.
func (*ContextPlus) QueryBoolPtr ¶
func (c *ContextPlus) QueryBoolPtr(key string) (b *bool)
QueryBoolPtr 获取bool值, 其中"",true, yes, on, y, t 都表示真, 其它值都表示假. 与GetBool不同的是, 当参数不存在时, 返回nil.
func (*ContextPlus) QueryInt32 ¶
func (c *ContextPlus) QueryInt32(key string, def int32) (value int32)
QueryInt32 获取int32值. 如果为空或解析失败, 返回默认值
func (*ContextPlus) QueryInt64 ¶
func (c *ContextPlus) QueryInt64(key string, def int64) (value int64)
QueryInt64 获取int64值. 如果为空或解析失败, 返回默认值