package ethgraphql import ( "bytes" "fmt" "net/http" ) // GraphiQL is an in-browser IDE for exploring GraphiQL APIs. // This handler returns GraphiQL when requested. // // For more information, see https://github.com/graphql/graphiql. type GraphiQL struct{} func respond(w http.ResponseWriter, body []byte, code int) { w.Header().Set("Content-Type", "application/json; charset=utf-8") w.Header().Set("X-Content-Type-Options", "nosniff") w.WriteHeader(code) _, _ = w.Write(body) } func errorJSON(msg string) []byte { buf := bytes.Buffer{} fmt.Fprintf(&buf, `{"error": "%s"}`, msg) return buf.Bytes() } func (h GraphiQL) ServeHTTP(w http.ResponseWriter, r *http.Request) { if r.Method != "GET" { respond(w, errorJSON("only GET requests are supported"), http.StatusMethodNotAllowed) return } w.Write(graphiql) } var graphiql = []byte(`
Loading...
`)