Skip to content
Open
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
10 changes: 9 additions & 1 deletion pinboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ var (
}

pinboardToken = ""

httpClient = &http.Client{}
)

// get checks if endpoint is a valid Pinboard API endpoint and then
Expand Down Expand Up @@ -103,7 +105,7 @@ func get(endpoint string, options interface{}) (body []byte, err error) {
u.RawQuery = q.Encode()

// Call APImethod with fully constructed URL.
res, err := http.Get(u.String())
res, err := httpClient.Get(u.String())
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -209,3 +211,9 @@ func values(i interface{}) (url.Values, error) {
func SetToken(token string) {
pinboardToken = token
}

// SetHttpClient sets teh actual http client instance to use to make calls.
// This can be overridden for caching purposes for example
func SetHttpClient(client *http.Client) {
httpClient = client
}