2025-01-08 02:00:34 +01:00

29 lines
556 B
Go

package web
import (
"fmt"
"net/http"
"git.kapelle.org/niklas/beerpong-elo/internal/repo"
"github.com/graphql-go/handler"
)
func CreateWebserver(repo repo.Repo) *http.ServeMux {
router := http.NewServeMux()
schema := createShema(repo)
router.HandleFunc("GET /hello", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hello, you've requested: %s\n", r.URL.Path)
})
gqlHandler := handler.New(&handler.Config{
Schema: &schema,
Pretty: true,
GraphiQL: true,
})
router.Handle("/graphql", gqlHandler)
return router
}