Documentation ¶
Index ¶
- Constants
- Variables
- func AddSkipPaths(paths ...string)
- func ApiSignVerify(cfg *SignConfig, getSecretKey func(accessKey string) (string, error)) 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 GetApiSignAccessKey(c *gin.Context) string
- 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
- type SignConfig
Constants ¶
View Source
const ( MRelease = 1 << iota // Gin release Mode MSwagger // enable Swagger MTraceId // request context add TraceId MReqLogger // request logging MDumpBody // Dump req | resp body MRecoverLogger // Recover logging write to qelog MPprof // http pprof MStd = MSwagger | MTraceId | MReqLogger | MDumpBody // default )
Variables ¶
View Source
var ( AuthorizationHeader = "X-Authorization" SignatureHeader = "X-Signature" )
View Source
var JWTDataKey = "jwt_claims_data"
Functions ¶
func ApiSignVerify ¶
func ApiSignVerify(cfg *SignConfig, getSecretKey func(accessKey string) (string, error)) gin.HandlerFunc
ApiSignVerify API signature, must setting get secretKey function
func ContextWithTraceId ¶
func ContextWithTraceId() gin.HandlerFunc
func DefaultEngine ¶
func DumpBodyLogger ¶
func DumpBodyLogger(skipPaths ...string) gin.HandlerFunc
DumpBodyLogger Dump req | resp body
func GenJWTToken ¶
func GetApiSignAccessKey ¶ added in v0.1.7
func JWTAuthVerify ¶
func JWTAuthVerify(enable bool, signingKey ...string) gin.HandlerFunc
JWTAuthVerify JWT auth verify signingKey custom signing key
func RecoveryLogger ¶
func RecoveryLogger() gin.HandlerFunc
RecoveryLogger GIN Recovery logging to qelog
func ReqLogger ¶
func ReqLogger(skipPaths ...string) gin.HandlerFunc
ReqLogger GIN handle request logging to qelog
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 ¶
type ResponseErr ¶
Click to show internal directories.
Click to hide internal directories.