Skip to content

Commit

Permalink
Named mutex
Browse files Browse the repository at this point in the history
  • Loading branch information
natdm committed Oct 16, 2017
1 parent 745a98f commit ab5be53
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions stripe.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ type Backend interface {

// BackendConfiguration is the internal implementation for making HTTP calls to Stripe.
type BackendConfiguration struct {
mu sync.Mutex
Type SupportedBackend
URL string
HTTPClient *http.Client
sync.Mutex
}

// SupportedBackend is an enumeration of supported Stripe endpoints.
Expand Down Expand Up @@ -241,8 +241,8 @@ func (s *BackendConfiguration) CallMultipart(method, path, key, boundary string,
// NewRequest is used by Call to generate an http.Request. It handles encoding
// parameters and attaching the appropriate headers.
func (s *BackendConfiguration) NewRequest(method, path, key, contentType string, body io.Reader, params *Params) (*http.Request, error) {
s.Lock()
defer s.Unlock()
s.mu.Lock()
defer s.mu.Unlock()
if !strings.HasPrefix(path, "/") {
path = "/" + path
}
Expand Down Expand Up @@ -298,8 +298,8 @@ func (s *BackendConfiguration) NewRequest(method, path, key, contentType string,
// the backend's HTTP client to execute the request and unmarshals the response
// into v. It also handles unmarshaling errors returned by the API.
func (s *BackendConfiguration) Do(req *http.Request, v interface{}) error {
s.Lock()
defer s.Unlock()
s.mu.Lock()
defer s.mu.Unlock()
if LogLevel > 1 {
Logger.Printf("Requesting %v %v%v\n", req.Method, req.URL.Host, req.URL.Path)
}
Expand Down

0 comments on commit ab5be53

Please sign in to comment.