Documentation
¶
Index ¶
- Variables
- func AccessLogger(pathPatterns ...*regexp.Regexp) gin.HandlerFunc
- func Auth(c *gin.Context)
- func CORS() gin.HandlerFunc
- func ContextWithAcceptLanguage(c *gin.Context)
- func ErrResp(c *gin.Context, key string, opts ...i18n.Option) map[string]any
- func RespInternal(c *gin.Context, msg ...string)
- type Token
- type TokenManager
- type Tokens
Constants ¶
This section is empty.
Variables ¶
View Source
var SkipAccessLog = "_skip_access_log_"
SkipAccessLog is a flag to skip access log
Functions ¶
func AccessLogger ¶
func AccessLogger(pathPatterns ...*regexp.Regexp) gin.HandlerFunc
AccessLogger a Logger middleware that will write the access logs to stdout or file.
func ContextWithAcceptLanguage ¶
ContextWithAcceptLanguage store accept language into c.Request.Context.
func RespInternal ¶
RespInternal gin response internal server error with msg.
Types ¶
type TokenManager ¶
type TokenManager struct { TokenSecretKey string `mapstructure:"token_secret_key"` AccessTokenExpiration time.Duration `mapstructure:"access_token_expiration"` RefreshTokenExpiration time.Duration `mapstructure:"refresh_token_expiration"` }
func NewTokenManager ¶
func NewTokenManager() (*TokenManager, error)
func (*TokenManager) GenerateAccessToken ¶
func (t *TokenManager) GenerateAccessToken(token *Token) (string, error)
func (*TokenManager) GenerateRefreshToken ¶
func (t *TokenManager) GenerateRefreshToken(token *Token) (string, error)
func (*TokenManager) ValidateToken ¶
func (t *TokenManager) ValidateToken(tokenString string) (*Token, error)
Click to show internal directories.
Click to hide internal directories.