MCPcopy Index your code
hub / github.com/github/github-mcp-server / newGHECHost

Function newGHECHost

pkg/utils/api.go:97–140  ·  view source on GitHub ↗
(hostname string)

Source from the content-addressed store, hash-verified

95}
96
97func newGHECHost(hostname string) (APIHost, error) {
98 u, err := url.Parse(hostname)
99 if err != nil {
100 return APIHost{}, fmt.Errorf("failed to parse GHEC URL: %w", err)
101 }
102
103 // Unsecured GHEC would be an error
104 if u.Scheme == "http" {
105 return APIHost{}, fmt.Errorf("GHEC URL must be HTTPS")
106 }
107
108 restURL, err := url.Parse(fmt.Sprintf("https://api.%s/", u.Hostname()))
109 if err != nil {
110 return APIHost{}, fmt.Errorf("failed to parse GHEC REST URL: %w", err)
111 }
112
113 gqlURL, err := url.Parse(fmt.Sprintf("https://api.%s/graphql", u.Hostname()))
114 if err != nil {
115 return APIHost{}, fmt.Errorf("failed to parse GHEC GraphQL URL: %w", err)
116 }
117
118 uploadURL, err := url.Parse(fmt.Sprintf("https://uploads.%s/", u.Hostname()))
119 if err != nil {
120 return APIHost{}, fmt.Errorf("failed to parse GHEC Upload URL: %w", err)
121 }
122
123 rawURL, err := url.Parse(fmt.Sprintf("https://raw.%s/", u.Hostname()))
124 if err != nil {
125 return APIHost{}, fmt.Errorf("failed to parse GHEC Raw URL: %w", err)
126 }
127
128 authorizationServerURL, err := url.Parse(fmt.Sprintf("https://%s/login/oauth", u.Hostname()))
129 if err != nil {
130 return APIHost{}, fmt.Errorf("failed to parse GHEC Authorization Server URL: %w", err)
131 }
132
133 return APIHost{
134 restURL: restURL,
135 gqlURL: gqlURL,
136 uploadURL: uploadURL,
137 rawURL: rawURL,
138 authorizationServerURL: authorizationServerURL,
139 }, nil
140}
141
142func newGHESHost(hostname string) (APIHost, error) {
143 u, err := url.Parse(hostname)

Callers 1

parseAPIHostFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected