Skip to content

Commit

Permalink
Support overriding the default API URL
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-stripe committed Sep 5, 2014
1 parent f9a8d9b commit ac3b102
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions stripe.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
"time"
)

// uri is the public Stripe URL for APIs.
const uri = "https://api.stripe.com/v1"
// url is the public Stripe URL for APIs.
const defaultUrl = "https://api.stripe.com/v1"

// apiversion is the currently supported API version
const apiversion = "2014-08-20"
Expand All @@ -29,6 +29,7 @@ type Backend interface {

// InternalBackend is the internal implementation for making HTTP calls to Stripe.
type InternalBackend struct {
Url string
HttpClient *http.Client
}

Expand All @@ -48,7 +49,10 @@ func SetDebug(value bool) {
// GetBackend returns the currently used backend in the binding.
func GetBackend() Backend {
if backend == nil {
backend = &InternalBackend{GetHttpClient()}
backend = &InternalBackend{
Url: defaultUrl,
HttpClient: GetHttpClient(),
}
}

return backend
Expand Down Expand Up @@ -79,7 +83,7 @@ func (s *InternalBackend) Call(method, path, token string, body *url.Values, v i
path = "/" + path
}

path = uri + path
path = s.Url + path

if body != nil && len(*body) > 0 {
path += "?" + body.Encode()
Expand Down

0 comments on commit ac3b102

Please sign in to comment.