Documentation ¶
Index ¶
- Variables
- func AccessLimit() gin.HandlerFunc
- func AppKey(c *gin.Context)
- func CorsByRules(corsCfg *config.CORS) gin.HandlerFunc
- func CustomError(c *gin.Context)
- func Fail(c *gin.Context, code int, msg string, data ...any)
- func GenToken(userId, companyId string, timeout time.Time, secret string) (string, error)
- func InitMiddleware(r *gin.Engine, cfg *config.AppCfg)
- func JWTAuthMiddleware() func(c *gin.Context)
- func LoggerToFile() gin.HandlerFunc
- func NoCache(c *gin.Context)
- func ParseToken(tokenString string, secret string) (jwt.StandardClaims, error)
- func ReqId(c *gin.Context)
- func ValidUserId() func(*gin.Context)
- func WhileIp() gin.HandlerFunc
- type Access
- type CustomResponseWriter
Constants ¶
This section is empty.
Variables ¶
View Source
var ( Secret = core.Cfg.JWT.SignKey //密码自行设定 TokenExpireDuration = time.Duration(core.Cfg.JWT.Expires) * time.Minute //设置过期时间 TokenLookup = "header: Authorization, query: token, cookie: jwt" TokenHeadName = "Bearer" // ErrEmptyAuthHeader can be thrown if authing with a HTTP header, the Decrypt header needs to be set ErrEmptyAuthHeader = errors.New("auth header is empty") // ErrInvalidAuthHeader indicates auth header is invalid, could for example have the wrong Realm name ErrInvalidAuthHeader = errors.New("auth header is invalid") // ErrEmptyQueryToken can be thrown if authing with URL Query, the query token variable is empty ErrEmptyQueryToken = errors.New("query token is empty") // ErrEmptyCookieToken can be thrown if authing with a cookie, the token cokie is empty ErrEmptyCookieToken = errors.New("cookie token is empty") // ErrEmptyParamToken can be thrown if authing with parameter in path, the parameter in path is empty ErrEmptyParamToken = errors.New("parameter token is empty") )
Functions ¶
func AccessLimit ¶
func AccessLimit() gin.HandlerFunc
func CustomError ¶
func JWTAuthMiddleware ¶
func LoggerToFile ¶
func LoggerToFile() gin.HandlerFunc
func NoCache ¶
NoCache is a middleware function that appends headers to prevent the client from caching the HTTP response.
func ParseToken ¶
func ValidUserId ¶
Types ¶
type CustomResponseWriter ¶
type CustomResponseWriter struct { gin.ResponseWriter // contains filtered or unexported fields }
func NewCustomResponseWriter ¶
func NewCustomResponseWriter(responseWriter gin.ResponseWriter) *CustomResponseWriter
Click to show internal directories.
Click to hide internal directories.