Documentation ¶
Index ¶
- Constants
- Variables
- func AddSkipPaths(paths ...string)
- func ApiSignVerify(enable bool, method sign.Method, supportMethods []string, ...) gin.HandlerFunc
- func ClientIP(c *gin.Context) string
- func ContextWithTraceId() gin.HandlerFunc
- func DefaultEngine(flags int) *gin.Engine
- func DumpBodyLogger(skipPaths ...string) gin.HandlerFunc
- func GenJWTToken(data string, ttl time.Duration, signingKey ...string) (token string, err error)
- func GetJWTDataFromContext(c *gin.Context) (string, bool)
- func JWTAuthVerify(enable bool, signingKey ...string) gin.HandlerFunc
- func RecoveryLogger() gin.HandlerFunc
- func ReqLogger(skipPaths ...string) gin.HandlerFunc
- func Resp(c *gin.Context, httpCode int, data interface{}, err error)
- func RespData(c *gin.Context, data interface{}, status ...int)
- func RespErr(c *gin.Context, err error, status ...int)
- func RespSuccess(c *gin.Context, status ...int)
- func SetJWTDataToContext(c *gin.Context, token string, signingKey ...string) error
- func ShouldBind(c *gin.Context, obj interface{}) error
- func ValidateStruct(obj interface{}) error
- type BaseResp
- type DataResp
- type ResponseErr
Constants ¶
View Source
const ( MRelease = 1 << iota // Gin release 模式 MSwagger // 开启Swagger // 中间件启用 MTraceId // 请求context 加入TraceId MReqLogger //请求日志 MDumpBody // Dump 请求参数&返回参数 MRecoverLogger // Recover 日志写入到日志中心 MStd = MSwagger | MTraceId | MReqLogger | MDumpBody // 默认 )
Variables ¶
View Source
var AuthorizationHeader = "X-Authorization"
View Source
var JWTDataKey = "jwt_claims_data"
View Source
var SignValidDuration = 5 * time.Second
View Source
var SignatureHeader = "X-Signature"
Functions ¶
func ApiSignVerify ¶
func ApiSignVerify(enable bool, method sign.Method, supportMethods []string, getSecretKey func(accessKey string) (string, error)) gin.HandlerFunc
ApiSignVerify API hmacSha1 接口签名 必需设置获取密钥的方法
func ContextWithTraceId ¶
func ContextWithTraceId() gin.HandlerFunc
func DefaultEngine ¶
func DumpBodyLogger ¶
func DumpBodyLogger(skipPaths ...string) gin.HandlerFunc
DumpBodyLogger Dump 请求和返回Body便于排查问题
func GenJWTToken ¶
func JWTAuthVerify ¶
func JWTAuthVerify(enable bool, signingKey ...string) gin.HandlerFunc
JWTAuthVerify JWT权限验证 signingKey 自定义的 加密Key, 如果没有就使用全局默认的
func SetJWTDataToContext ¶
func ShouldBind ¶
func ValidateStruct ¶
func ValidateStruct(obj interface{}) error
Types ¶
type BaseResp ¶
func NewBaseResp ¶
type DataResp ¶
type DataResp struct { *BaseResp Data interface{} `json:"data"` }
func NewDataResp ¶
Click to show internal directories.
Click to hide internal directories.