Skip to content

Commit 99f92b9

Browse files
committed
add Conetent-Type multipart/form-data
1 parent 59006c0 commit 99f92b9

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

handler.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ import (
1313
)
1414

1515
const (
16-
ContentTypeJSON = "application/json"
17-
ContentTypeGraphQL = "application/graphql"
18-
ContentTypeFormURLEncoded = "application/x-www-form-urlencoded"
16+
ContentTypeJSON = "application/json"
17+
ContentTypeGraphQL = "application/graphql"
18+
ContentTypeFormURLEncoded = "application/x-www-form-urlencoded"
19+
ContentTypeMultipartFormData = "multipart/form-data"
1920
)
2021

2122
type Handler struct {
@@ -94,7 +95,15 @@ func NewRequestOptions(r *http.Request) *RequestOptions {
9495
}
9596

9697
return &RequestOptions{}
97-
98+
case ContentTypeMultipartFormData:
99+
variables := make(map[string]interface{}, len(r.FormValue("variables")))
100+
variablesStr := r.FormValue("variables")
101+
json.Unmarshal([]byte(variablesStr), &variables)
102+
return &RequestOptions{
103+
Query: r.FormValue("query"),
104+
Variables: variables,
105+
OperationName: r.FormValue("operationName"),
106+
}
98107
case ContentTypeJSON:
99108
fallthrough
100109
default:

0 commit comments

Comments
 (0)