client: add prefix to KeysAPI

release-2.0
Brian Waldon 2014-10-24 15:39:23 -07:00
parent 2b9cabcbcd
commit 73e48068c2
2 changed files with 9 additions and 16 deletions

View File

@ -53,21 +53,6 @@ type httpClient struct {
timeout time.Duration
}
func newHTTPClient(tr *http.Transport, ep string, to time.Duration) (*httpClient, error) {
u, err := url.Parse(ep)
if err != nil {
return nil, err
}
c := &httpClient{
transport: tr,
endpoint: *u,
timeout: to,
}
return c, nil
}
func (c *httpClient) doWithTimeout(act httpAction) (*http.Response, []byte, error) {
ctx, cancel := context.WithTimeout(context.Background(), c.timeout)
defer cancel()

View File

@ -50,11 +50,19 @@ func NewDiscoveryKeysAPI(tr *http.Transport, ep string, to time.Duration) (KeysA
}
func newHTTPKeysAPIWithPrefix(tr *http.Transport, ep string, to time.Duration, prefix string) (*HTTPKeysAPI, error) {
c, err := newHTTPClient(tr, ep, to)
u, err := url.Parse(ep)
if err != nil {
return nil, err
}
u.Path = path.Join(u.Path, prefix)
c := &httpClient{
transport: tr,
endpoint: *u,
timeout: to,
}
kAPI := HTTPKeysAPI{
client: c,
}