Documentation
¶
Index ¶
- Constants
- Variables
- func Metrics(name string, args ...any) gin.HandlerFunc
- func ResponseCsv(c *gin.Context, data CsvData)
- func ResponseError(c *gin.Context, err error)
- func ResponseSuccess(c *gin.Context, data any)
- func Wrap(controller func(c *gin.Context) (any, error)) gin.HandlerFunc
- type CsvData
- type Jwt
- func (j *Jwt[T, KEY]) ClaimsFromContext(c *gin.Context) (data T, err error)
- func (j *Jwt[T, KEY]) Config() JwtConfig
- func (j *Jwt[T, KEY]) Generate(data T, optNow ...time.Time) (string, string, error)
- func (j *Jwt[T, KEY]) Middleware(c *gin.Context)
- func (j *Jwt[T, KEY]) RawClaimsFromContext(c *gin.Context) (*JwtClaims[T], error)
- func (j *Jwt[T, KEY]) Validate(tokenString string) (*JwtClaims[T], error)
- type JwtClaims
- type JwtConfig
- type PrivateKey
- type SigningMethod
Constants ¶
View Source
const HttpStatusInternalError = 600
Variables ¶
View Source
var SigningMethods struct { // RSA RS256 SigningMethod[*rsa.PrivateKey] // EdDSA EdDSA SigningMethod[ed25519.PrivateKey] }
Functions ¶
func ResponseCsv ¶
func ResponseError ¶
func ResponseSuccess ¶
Types ¶
type Jwt ¶
type Jwt[DATA any, KEY PrivateKey] struct { // contains filtered or unexported fields }
func MustNewRandomJwt ¶
func MustNewRandomJwt[T any, KEY PrivateKey](config JwtConfig, method SigningMethod[KEY]) *Jwt[T, KEY]
func NewJwt ¶
func NewJwt[T any, KEY PrivateKey](config JwtConfig, method SigningMethod[KEY]) (*Jwt[T, KEY], error)
func (*Jwt[T, KEY]) ClaimsFromContext ¶
ClaimsFromContext returns JWT claims that injected via middleware.
func (*Jwt[T, KEY]) Middleware ¶
Middleware validates JWT token from HTTP Authorization header that in format of 'Bearer xxx'.
func (*Jwt[T, KEY]) RawClaimsFromContext ¶ added in v0.6.7
ClaimsFromContext returns JWT claims that injected via middleware.
type PrivateKey ¶
type PrivateKey interface { Public() crypto.PublicKey Equal(x crypto.PrivateKey) bool }
type SigningMethod ¶
type SigningMethod[T PrivateKey] interface { MustGenerateKey() T ToPEM(key T) []byte FromPEM(data []byte) (T, error) JwtSigningMethod() jwt.SigningMethod }
Click to show internal directories.
Click to hide internal directories.