MCPcopy
hub / github.com/mislav/hub / simpleApi

Method simpleApi

github/client.go:1029–1054  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1027}
1028
1029func (client *Client) simpleApi() (c *simpleClient, err error) {
1030 err = client.ensureAccessToken()
1031 if err != nil {
1032 return
1033 }
1034
1035 if client.cachedClient != nil {
1036 c = client.cachedClient
1037 return
1038 }
1039
1040 c = client.apiClient()
1041 c.PrepareRequest = func(req *http.Request) {
1042 clientDomain := normalizeHost(client.Host.Host)
1043 if strings.HasPrefix(clientDomain, "api.github.") {
1044 clientDomain = strings.TrimPrefix(clientDomain, "api.")
1045 }
1046 requestHost := strings.ToLower(req.URL.Host)
1047 if requestHost == clientDomain || strings.HasSuffix(requestHost, "."+clientDomain) {
1048 req.Header.Set("Authorization", "token "+client.Host.AccessToken)
1049 }
1050 }
1051
1052 client.cachedClient = c
1053 return
1054}
1055
1056func (client *Client) apiClient() *simpleClient {
1057 unixSocket := os.ExpandEnv(client.Host.UnixSocket)

Callers 15

FetchPullRequestsMethod · 0.95
PullRequestMethod · 0.95
PullRequestPatchMethod · 0.95
CreatePullRequestMethod · 0.95
RequestReviewMethod · 0.95
CommitPatchMethod · 0.95
GistPatchMethod · 0.95
RepositoryMethod · 0.95
CreateRepositoryMethod · 0.95
DeleteRepositoryMethod · 0.95
FetchReleasesMethod · 0.95
CreateReleaseMethod · 0.95

Calls 4

ensureAccessTokenMethod · 0.95
apiClientMethod · 0.95
normalizeHostFunction · 0.85
SetMethod · 0.45

Tested by

no test coverage detected