Skip to content

Commit 0c9388b

Browse files
committed
Added SetBaseURL method deprecated SetHostURL, to be removed in next major release #441
1 parent 1792d62 commit 0c9388b

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

client.go

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ type (
9292
// Resty also provides an options to override most of the client settings
9393
// at request level.
9494
type Client struct {
95-
HostURL string
95+
BaseURL string
96+
HostURL string // Deprecated: use BaseURL instead. To be removed in v3.0.0 release.
9697
QueryParam url.Values
9798
FormData url.Values
9899
Header http.Header
@@ -154,8 +155,25 @@ type User struct {
154155
//
155156
// // Setting HTTPS address
156157
// client.SetHostURL("https://myjeeva.com")
158+
//
159+
// Deprecated: use SetBaseURL instead. To be removed in v3.0.0 release.
157160
func (c *Client) SetHostURL(url string) *Client {
158-
c.HostURL = strings.TrimRight(url, "/")
161+
c.SetBaseURL(url)
162+
return c
163+
}
164+
165+
// SetBaseURL method is to set Base URL in the client instance. It will be used with request
166+
// raised from this client with relative URL
167+
// // Setting HTTP address
168+
// client.SetBaseURL("http://myjeeva.com")
169+
//
170+
// // Setting HTTPS address
171+
// client.SetBaseURL("https://myjeeva.com")
172+
//
173+
// Since v2.7.0
174+
func (c *Client) SetBaseURL(url string) *Client {
175+
c.BaseURL = strings.TrimRight(url, "/")
176+
c.HostURL = c.BaseURL
159177
return c
160178
}
161179

0 commit comments

Comments
 (0)