mirror of
https://github.com/dstotijn/hetty.git
synced 2025-07-01 18:47:29 -04:00
Move gql handler out of main
, improve admin route matching
This commit is contained in:
21
pkg/api/http.go
Normal file
21
pkg/api/http.go
Normal file
@ -0,0 +1,21 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/99designs/gqlgen/graphql/handler"
|
||||
"github.com/99designs/gqlgen/graphql/playground"
|
||||
"github.com/gorilla/mux"
|
||||
)
|
||||
|
||||
func HTTPHandler(resolver *Resolver, gqlEndpoint string) http.Handler {
|
||||
router := mux.NewRouter().SkipClean(true)
|
||||
router.Methods("POST").Handler(
|
||||
handler.NewDefaultServer(NewExecutableSchema(Config{
|
||||
Resolvers: resolver,
|
||||
})),
|
||||
)
|
||||
router.Methods("GET").Handler(playground.Handler("GraphQL Playground", gqlEndpoint))
|
||||
|
||||
return router
|
||||
}
|
Reference in New Issue
Block a user