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

add NewBackendsWithConfig helper #1748

Merged
merged 3 commits into from
Oct 13, 2023
Merged
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
13 changes: 11 additions & 2 deletions stripe.go
Original file line number Diff line number Diff line change
Expand Up @@ -1116,8 +1116,7 @@ func Int64Slice(v []int64) []*int64 {
return out
}

// NewBackends creates a new set of backends with the given HTTP client. You
// should only need to use this for testing purposes or on App Engine.
// NewBackends creates a new set of backends with the given HTTP client.
func NewBackends(httpClient *http.Client) *Backends {
apiConfig := &BackendConfig{HTTPClient: httpClient}
connectConfig := &BackendConfig{HTTPClient: httpClient}
Expand All @@ -1129,6 +1128,16 @@ func NewBackends(httpClient *http.Client) *Backends {
}
}

// NewBackendsWithConfig creates a new set of backends with the given config for all backends.
// Useful for setting up client with a custom logger and http client.
func NewBackendsWithConfig(config *BackendConfig) *Backends {
return &Backends{
API: GetBackendWithConfig(APIBackend, config),
Connect: GetBackendWithConfig(ConnectBackend, config),
Uploads: GetBackendWithConfig(UploadsBackend, config),
}
}

// ParseID attempts to parse a string scalar from a given JSON value which is
// still encoded as []byte. If the value was a string, it returns the string
// along with true as the second return value. If not, false is returned as the
Expand Down
Loading