Skip to content

Commit

Permalink
Added SetBaseURL method deprecated SetHostURL, to be removed in next …
Browse files Browse the repository at this point in the history
…major release #441
  • Loading branch information
jeevatkm committed Oct 25, 2021
1 parent 1792d62 commit 0c9388b
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions client.go
Expand Up @@ -92,7 +92,8 @@ type (
// Resty also provides an options to override most of the client settings
// at request level.
type Client struct {
HostURL string
BaseURL string
HostURL string // Deprecated: use BaseURL instead. To be removed in v3.0.0 release.
QueryParam url.Values
FormData url.Values
Header http.Header
Expand Down Expand Up @@ -154,8 +155,25 @@ type User struct {
//
// // Setting HTTPS address
// client.SetHostURL("https://myjeeva.com")
//
// Deprecated: use SetBaseURL instead. To be removed in v3.0.0 release.
func (c *Client) SetHostURL(url string) *Client {
c.HostURL = strings.TrimRight(url, "/")
c.SetBaseURL(url)
return c
}

// SetBaseURL method is to set Base URL in the client instance. It will be used with request
// raised from this client with relative URL
// // Setting HTTP address
// client.SetBaseURL("http://myjeeva.com")
//
// // Setting HTTPS address
// client.SetBaseURL("https://myjeeva.com")
//
// Since v2.7.0
func (c *Client) SetBaseURL(url string) *Client {
c.BaseURL = strings.TrimRight(url, "/")
c.HostURL = c.BaseURL
return c
}

Expand Down

0 comments on commit 0c9388b

Please sign in to comment.