client: add prefix to KeysAPI
parent
2b9cabcbcd
commit
73e48068c2
|
@ -53,21 +53,6 @@ type httpClient struct {
|
||||||
timeout time.Duration
|
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) {
|
func (c *httpClient) doWithTimeout(act httpAction) (*http.Response, []byte, error) {
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), c.timeout)
|
ctx, cancel := context.WithTimeout(context.Background(), c.timeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
|
@ -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) {
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
u.Path = path.Join(u.Path, prefix)
|
||||||
|
|
||||||
|
c := &httpClient{
|
||||||
|
transport: tr,
|
||||||
|
endpoint: *u,
|
||||||
|
timeout: to,
|
||||||
|
}
|
||||||
|
|
||||||
kAPI := HTTPKeysAPI{
|
kAPI := HTTPKeysAPI{
|
||||||
client: c,
|
client: c,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue