requestName returns the name responses are stored under: "graphql Operation" for GraphQL calls and "METHOD /path" for REST calls to the API host. Calls to any other host keep the host in the name, such as "POST uploads.github.com/upload".
(method, hostname, path string, body []byte)
| 54 | // any other host keep the host in the name, such as |
| 55 | // "POST uploads.github.com/upload". |
| 56 | func requestName(method, hostname, path string, body []byte) (string, *graphQLRequest) { |
| 57 | hostname = strings.ToLower(hostname) |
| 58 | if path == "" { |
| 59 | path = "/" |
| 60 | } |
| 61 | if method == http.MethodPost && isAPIHost(hostname) && path == "/graphql" { |
| 62 | if gql := parseGraphQL(body); gql != nil { |
| 63 | return "graphql " + gql.operationLabel(), gql |
| 64 | } |
| 65 | } |
| 66 | if isAPIHost(hostname) { |
| 67 | return method + " " + path, nil |
| 68 | } |
| 69 | return method + " " + hostname + path, nil |
| 70 | } |
| 71 | |
| 72 | func parseGraphQL(body []byte) *graphQLRequest { |
| 73 | var payload struct { |