Skip to content

Commit

Permalink
add Conetent-Type multipart/form-data
Browse files Browse the repository at this point in the history
  • Loading branch information
chienfuchen32 committed Aug 10, 2018
1 parent 59006c0 commit 99f92b9
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions handler.go
Expand Up @@ -13,9 +13,10 @@ import (
)

const (
ContentTypeJSON = "application/json"
ContentTypeGraphQL = "application/graphql"
ContentTypeFormURLEncoded = "application/x-www-form-urlencoded"
ContentTypeJSON = "application/json"
ContentTypeGraphQL = "application/graphql"
ContentTypeFormURLEncoded = "application/x-www-form-urlencoded"
ContentTypeMultipartFormData = "multipart/form-data"
)

type Handler struct {
Expand Down Expand Up @@ -94,7 +95,15 @@ func NewRequestOptions(r *http.Request) *RequestOptions {
}

return &RequestOptions{}

case ContentTypeMultipartFormData:
variables := make(map[string]interface{}, len(r.FormValue("variables")))
variablesStr := r.FormValue("variables")
json.Unmarshal([]byte(variablesStr), &variables)
return &RequestOptions{
Query: r.FormValue("query"),
Variables: variables,
OperationName: r.FormValue("operationName"),
}
case ContentTypeJSON:
fallthrough
default:
Expand Down

0 comments on commit 99f92b9

Please sign in to comment.