+
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions github/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,11 @@ func NewClient(httpClient *http.Client) *Client {
return c
}

// NewClientWithEnvProxy enhances NewClient with the HttpProxy env.
func NewClientWithEnvProxy() *Client {
return NewClient(&http.Client{Transport: &http.Transport{Proxy: http.ProxyFromEnvironment}})
}

// NewTokenClient returns a new GitHub API client authenticated with the provided token.
func NewTokenClient(ctx context.Context, token string) *Client {
return NewClient(oauth2.NewClient(ctx, oauth2.StaticTokenSource(&oauth2.Token{AccessToken: token})))
Expand Down
7 changes: 7 additions & 0 deletions github/github_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,13 @@ func TestNewClient(t *testing.T) {
}
}

func TestNewClientWithEnvProxy(t *testing.T) {
client := NewClientWithEnvProxy()
if got, want := client.BaseURL.String(), defaultBaseURL; got != want {
t.Errorf("NewClient BaseURL is %v, want %v", got, want)
}
}

func TestClient(t *testing.T) {
c := NewClient(nil)
c2 := c.Client()
Expand Down
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载