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 May 30, 2018
1 parent c1c8ee7 commit 429ed61
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ 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 {
Schema *graphql.Schema
Schema *graphql.Schema
pretty bool
graphiql bool
}
Expand Down Expand Up @@ -92,7 +93,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 429ed61

Please sign in to comment.