| 232 | } |
| 233 | |
| 234 | func GraphQLQuery(body string, cb func(string, map[string]interface{})) Responder { |
| 235 | return func(req *http.Request) (*http.Response, error) { |
| 236 | var bodyData struct { |
| 237 | Query string |
| 238 | Variables map[string]interface{} |
| 239 | } |
| 240 | err := decodeJSONBody(req, &bodyData) |
| 241 | if err != nil { |
| 242 | return nil, err |
| 243 | } |
| 244 | cb(bodyData.Query, bodyData.Variables) |
| 245 | |
| 246 | return httpResponse(200, req, bytes.NewBufferString(body)), nil |
| 247 | } |
| 248 | } |
| 249 | |
| 250 | // ScopesResponder returns a response with a 200 status code and the given OAuth scopes. |
| 251 | func ScopesResponder(scopes string) func(*http.Request) (*http.Response, error) { |