Skip to content

Commit

Permalink
add NewBackendsWithConfig helper (#1748)
Browse files Browse the repository at this point in the history
  • Loading branch information
epelc authored Oct 13, 2023
1 parent 755ad0c commit df184f1
Showing 1 changed file with 11 additions and 2 deletions.
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

0 comments on commit df184f1

Please sign in to comment.