0

每当我用路由器更改http时,当我使用路由器而不是http时,我无法访问我的graphql游乐场,我得到404

func main() {
    port := os.Getenv("PORT")
    if port == "" {
        port = defaultPort
    }
    router := chi.NewRouter()
    srv := handler.NewDefaultServer(generated.NewExecutableSchema(generated.Config{Resolvers: &graph.Resolver{}}))

    // http.Handle("/", playground.Handler("GraphQL playground", "/query"))
    // http.Handle("/query", srv)
    router.Handle("/", playground.Handler("GraphQL playground", "/query"))
    router.Handle("/query", srv)

    log.Printf("connect to http://localhost:%s/ for GraphQL playground", port)
    log.Fatal(http.ListenAndServe(":"+port, nil))
}

本地主机:8080

4

0 回答 0