Skip to content

Commit

Permalink
complement url
Browse files Browse the repository at this point in the history
  • Loading branch information
sp-yduck committed Jul 21, 2023
1 parent 8ae105f commit a63d7cb
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions rest/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"io/ioutil"
"net/http"
"net/url"
"strings"

"github.com/pkg/errors"

Expand Down Expand Up @@ -83,6 +84,12 @@ func withLogin() ClientOption {
}

func (c *RESTClient) Do(httpMethod, urlPath string, req, v interface{}) error {
if !strings.HasPrefix(c.endpoint, "http") {
c.endpoint = "http://" + c.endpoint
}
if !strings.HasSuffix(c.endpoint, "/api2/json") {
c.endpoint += "/api2/json"
}
url, err := url.JoinPath(c.endpoint, urlPath)
if err != nil {
return err
Expand Down

0 comments on commit a63d7cb

Please sign in to comment.