Skip to content

Commit a63d7cb

Browse files
committed
complement url
1 parent 8ae105f commit a63d7cb

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

rest/client.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"io/ioutil"
99
"net/http"
1010
"net/url"
11+
"strings"
1112

1213
"github.com/pkg/errors"
1314

@@ -83,6 +84,12 @@ func withLogin() ClientOption {
8384
}
8485

8586
func (c *RESTClient) Do(httpMethod, urlPath string, req, v interface{}) error {
87+
if !strings.HasPrefix(c.endpoint, "http") {
88+
c.endpoint = "http://" + c.endpoint
89+
}
90+
if !strings.HasSuffix(c.endpoint, "/api2/json") {
91+
c.endpoint += "/api2/json"
92+
}
8693
url, err := url.JoinPath(c.endpoint, urlPath)
8794
if err != nil {
8895
return err

0 commit comments

Comments
 (0)