| 199 | } |
| 200 | |
| 201 | func RESTPayload(responseStatus int, responseBody string, cb func(payload map[string]interface{})) Responder { |
| 202 | return func(req *http.Request) (*http.Response, error) { |
| 203 | bodyData := make(map[string]interface{}) |
| 204 | err := decodeJSONBody(req, &bodyData) |
| 205 | if err != nil { |
| 206 | return nil, err |
| 207 | } |
| 208 | cb(bodyData) |
| 209 | |
| 210 | header := http.Header{ |
| 211 | "Content-Type": []string{"application/json"}, |
| 212 | } |
| 213 | return httpResponseWithHeader(responseStatus, req, bytes.NewBufferString(responseBody), header), nil |
| 214 | } |
| 215 | } |
| 216 | |
| 217 | func GraphQLMutation(body string, cb func(map[string]interface{})) Responder { |
| 218 | return func(req *http.Request) (*http.Response, error) { |