我正在尝试在 Go 中将 Auth0 与 Martini 一起使用。我正在使用他们的示例,但无论我尝试什么,我似乎都无法使其正常工作。这是我的代码:package mainimport ( "flag" "github.com/go-martini/martini" "github.com/martini-contrib/render" "github.com/auth0/go-jwt-middleware" "encoding/base64" "github.com/dgrijalva/jwt-go" "net/http")func main() { m := martini.Classic() port := flag.String("port", "8000", "HTTP Port") flag.Parse() jwtMiddleware := jwtmiddleware.New(jwtmiddleware.Options{ ValidationKeyGetter: func(token *jwt.Token) (interface{}, error) { decoded, err := base64.URLEncoding.DecodeString("<token>") if err != nil { return nil, err } return decoded, nil }, }) m.Use(render.Renderer(render.Options{ IndentJSON: true, // Output human readable JSON })) m.Get("/", jwtMiddleware.Handler, func(res http.ResponseWriter, req *http.Request) { // res and req are injected by Martini res.WriteHeader(200) // HTTP 200 }) // Get the PORT from the environment. m.RunOnAddr(":" + *port)}当我运行它时,我感到恐慌,说 Value not found for type http.Handler如果我将 更改jwtMiddleware.Handler为jwtMiddleware.HandlerWithNext,我会对Value not found for type http.HandlerFunc.有没有人知道我做错了什么?
1 回答
- 1 回答
- 0 关注
- 183 浏览
添加回答
举报
0/150
提交
取消