MCPcopy Create free account
hub / github.com/cli/cli / requestName

Function requestName

script/ghmock/request.go:56–70  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

54// any other host keep the host in the name, such as
55// "POST uploads.github.com/upload".
56func 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
72func parseGraphQL(body []byte) *graphQLRequest {
73 var payload struct {

Callers 2

ServeHTTPMethod · 0.85
TestRequestNameFunction · 0.85

Calls 3

isAPIHostFunction · 0.85
parseGraphQLFunction · 0.85
operationLabelMethod · 0.80

Tested by 1

TestRequestNameFunction · 0.68