// Handler builds http handler to display GraphQL Playground page,
// where endpoint is the target of GraphQL API handler.
// If error will occur on building stage the panic is throwed.
Handler builds http handler to display GraphQL Playground page,
where endpoint is the target of GraphQL API handler.
If error will occur on building stage the panic is throwed.
// Handler builds http handler to display GraphQL Playground page // where endpoint is the target of GraphQL API handler . // If error will occur on building stage the panic is throwed .
func Handler(endpoint string, options ...Option) http.HandlerFunc {
	data := settings{
		Title:      "GraphQL Playground",
		ReactBuild: "@" + DefaultReactBuild,
		Endpoint:   endpoint,
	}
	for _, o := range options {
		o(&data)
	}
	buf := &bytes.Buffer{}
	err := playground.Execute(buf, map[string]string{
		"title":    data.Title,
		"version":  data.ReactBuild,
		"endpoint": data.Endpoint,
	})
	if err != nil {
		panic(err)
	}
	return func(w http.ResponseWriter, r *http.Request) {
		w.Header().Add("Content-Type", "text/html; charset=utf-8")
		w.Write(buf.Bytes())
	}
}
func Handler ( endpoint string , options ... Option ) http . HandlerFunc { data := settings { Title : " " , ReactBuild : " " + DefaultReactBuild , Endpoint : endpoint , } for _ , o := range options { o ( & data ) } buf := & bytes . Buffer { } err := playground . Execute ( buf , map [ string ] string { " " : data . Title , " " : data . ReactBuild , " " : data . Endpoint , } ) if err != nil { panic ( err ) } return func ( w http . ResponseWriter , r * http . Request ) { w . Header ( ) . Add ( " " , " " ) w . Write ( buf . Bytes ( ) ) } }
Handler builds http handler to display GraphQL Playground page,
where endpoint is the target of GraphQL API handler.
Handler builds http handler to display GraphQL Playground page where endpoint is the target of GraphQL API handler .