Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add HTTPClient option #86

Merged
merged 1 commit into from
Nov 13, 2019
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
4 changes: 4 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,11 @@ type ClientOptions struct {
Environment string
// Maximum number of breadcrumbs.
MaxBreadcrumbs int
// An optional pointer to `http.Client` that will be used with a default HTTPTransport.
// Using your own client will make HTTPTransport, HTTPProxy, HTTPSProxy and CaCerts options ignored.
HTTPClient *http.Client
// An optional pointer to `http.Transport` that will be used with a default HTTPTransport.
// Using your own transport will make HTTPProxy, HTTPSProxy and CaCerts options ignored.
HTTPTransport *http.Transport
// An optional HTTP proxy to use.
// This will default to the `http_proxy` environment variable.
Expand Down
20 changes: 14 additions & 6 deletions transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,13 @@ func (t *HTTPTransport) Configure(options ClientOptions) {
}
}

t.client = &http.Client{
Transport: t.transport,
Timeout: t.Timeout,
if options.HTTPClient != nil {
t.client = options.HTTPClient
} else {
t.client = &http.Client{
Transport: t.transport,
Timeout: t.Timeout,
}
}

t.start.Do(func() {
Expand Down Expand Up @@ -276,9 +280,13 @@ func (t *HTTPSyncTransport) Configure(options ClientOptions) {
}
}

t.client = &http.Client{
Transport: t.transport,
Timeout: t.Timeout,
if options.HTTPClient != nil {
kamilogorek marked this conversation as resolved.
Show resolved Hide resolved
t.client = options.HTTPClient
} else {
t.client = &http.Client{
Transport: t.transport,
Timeout: t.Timeout,
}
}
}

Expand Down