Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
jwt
✓ github.com/hertz-contrib/jwt
Basic setup of JWT middleware for Hertz.
package main
import (
"context"
"github.com/cloudwego/hertz/pkg/app"
"github.com/cloudwego/hertz/pkg/app/server"
"github.com/hertz-contrib/jwt"
)
func main() {
h := server.Default()
authMiddleware, _ := jwt.New(&jwt.HertzJWTMiddleware{
Realm: "test zone",
Key: []byte("secret key"),
Timeout: jwt.DefaultTimeout,
MaxRefresh: jwt.DefaultMaxRefresh,
Authenticator: func(ctx context.Context, c *app.RequestContext) (interface{}, error) {
return nil, jwt.ErrMissingLoginValues
},
})
h.POST("/login", authMiddleware.LoginHandler)
h.Spin()
}
Debug
Known issues
No known issues recorded.
Upgrade
Version history
1.0.4latest on pkg.go.dev
Audit
Dependencies
No dependency data recorded yet.