Browse Source

client: add prefix to KeysAPI

Brian Waldon 11 years ago
parent
commit
73e48068c2
2 changed files with 9 additions and 16 deletions
  1. 0 15
      client/http.go
  2. 9 1
      client/keys.go

+ 0 - 15
client/http.go

@@ -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()

+ 9 - 1
client/keys.go

@@ -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,
 	}