我在代码中使用router作为:
router := chi.NewRouter()
router.Use(auth.Middleware())
srv := handler.NewDefaultServer(generated.NewExecutableSchema(generated.Config{Resolvers: &graph.Resolver{}}))
router.Handle("/", playground.Handler("GraphQL playground", "/query"))
router.Handle("/query", srv)
得到的错误如下:
{
"errors": {
"message": "Unexpected token p in JSON at position 4",
"stack": "SyntaxError: Unexpected token p in JSON at position 4"
}
}
但当我尝试使用它与http.Handle
它不显示错误,但代码内auth.middleware
不运行。
1条答案
按热度按时间gopyfrb31#
你可以试试这样:=