Merge pull request #20046 from karalabe/graphql-fix-web-and-decoding

common, graphql: fix hash/address decoding + UI content type
This commit is contained in:
Péter Szilágyi 2019-09-10 13:33:01 +03:00 committed by GitHub
commit 4f6bf2f1c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -149,7 +149,7 @@ func (h *Hash) UnmarshalGraphQL(input interface{}) error {
var err error
switch input := input.(type) {
case string:
*h = HexToHash(input)
err = h.UnmarshalText([]byte(input))
default:
err = fmt.Errorf("Unexpected type for Bytes32: %v", input)
}
@ -288,7 +288,7 @@ func (a *Address) UnmarshalGraphQL(input interface{}) error {
var err error
switch input := input.(type) {
case string:
*a = HexToAddress(input)
err = a.UnmarshalText([]byte(input))
default:
err = fmt.Errorf("Unexpected type for Address: %v", input)
}

View File

@ -52,7 +52,7 @@ func (h GraphiQL) ServeHTTP(w http.ResponseWriter, r *http.Request) {
respond(w, errorJSON("only GET requests are supported"), http.StatusMethodNotAllowed)
return
}
w.Header().Set("Content-Type", "text/html")
w.Write(graphiql)
}