mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
client: add prefix to KeysAPI
This commit is contained in:
parent
2b9cabcbcd
commit
73e48068c2
@ -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()
|
||||
|
@ -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,
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user