We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I Implemented the Jwt-Middleware (JwtVerify(...)) the same way as you did:
func JwtVerify(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { var tk = r.Header.Get("x-access-token") // Grab the token from the header tk = strings.TrimSpace(tk) if tk == "" { // Token is missing, returns with error code 403 Unauthorized w.WriteHeader(http.StatusForbidden) json.NewEncoder(w).Encode(Exception{Message: "Missing auth token"}) return } claims := &models.Token{} _, err := jwt.ParseWithClaims(tk, claims, func(token *jwt.Token) (interface{}, error) { return []byte("secret"), nil }) if err != nil { w.WriteHeader(http.StatusForbidden) json.NewEncoder(w).Encode(Exception{Message: err.Error()}) return } ctx := context.WithValue(r.Context(), "user", claims) next.ServeHTTP(w, r.WithContext(ctx)) }) }
When I run the program, the following error occurs:
auth/middleware.go:30:45: cannot use func literal (type func(*jwt.Token) (interface {}, error)) as type jwt.Keyfunc in argument to jwt.ParseWithClaims
My IDE also shows an error:
Cannot use 'func(token *jwt.Token) (interface{}, error)' (type func(token *jwt.Token) (interface{}, error)) as type Keyfunc
I have imported the JWT (and all other packages) via Dep.
Have you come across this problem before?
Thank you & best regards
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I Implemented the Jwt-Middleware (JwtVerify(...)) the same way as you did:
When I run the program, the following error occurs:
auth/middleware.go:30:45: cannot use func literal (type func(*jwt.Token) (interface {}, error)) as type jwt.Keyfunc in argument to jwt.ParseWithClaims
My IDE also shows an error:
Cannot use 'func(token *jwt.Token) (interface{}, error)' (type func(token *jwt.Token) (interface{}, error)) as type Keyfunc
I have imported the JWT (and all other packages) via Dep.
Have you come across this problem before?
Thank you & best regards
The text was updated successfully, but these errors were encountered: