| 42 | } |
| 43 | |
| 44 | func GraphQL(q string) Matcher { |
| 45 | re := regexp.MustCompile(q) |
| 46 | |
| 47 | return func(req *http.Request) bool { |
| 48 | if !strings.EqualFold(req.Method, "POST") { |
| 49 | return false |
| 50 | } |
| 51 | if req.URL.Path != "/graphql" && req.URL.Path != "/api/graphql" { |
| 52 | return false |
| 53 | } |
| 54 | |
| 55 | var bodyData struct { |
| 56 | Query string |
| 57 | } |
| 58 | _ = decodeJSONBody(req, &bodyData) |
| 59 | |
| 60 | return re.MatchString(bodyData.Query) |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | func GraphQLMutationMatcher(q string, cb func(map[string]interface{}) bool) Matcher { |
| 65 | re := regexp.MustCompile(q) |