-
Notifications
You must be signed in to change notification settings - Fork 718
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
1,333 additions
and
1,212 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -95,6 +95,7 @@ type Client struct { | |
notParseResponse bool | ||
debugBodySizeLimit int64 | ||
logPrefix string | ||
pathParams map[string]string | ||
beforeRequest []func(*Client, *Request) error | ||
udBeforeRequest []func(*Client, *Request) error | ||
preReqHook func(*Client, *Request) error | ||
|
@@ -311,6 +312,7 @@ func (c *Client) R() *Request { | |
client: c, | ||
bodyBuf: nil, | ||
multipartFiles: []*File{}, | ||
pathParams: make(map[string]string), | ||
} | ||
|
||
return r | ||
|
@@ -719,6 +721,25 @@ func (c *Client) SetLogPrefix(prefix string) *Client { | |
return c | ||
} | ||
|
||
// SetPathParams method sets multiple URL path key-value pairs at one go in the | ||
// resty client instance. | ||
// resty.SetPathParams(map[string]string{ | ||
// "userId": "[email protected]", | ||
// "subAccountId": "100002", | ||
// }) | ||
// | ||
// Result: | ||
// URL - /v1/users/{userId}/{subAccountId}/details | ||
// Composed URL - /v1/users/[email protected]/100002/details | ||
// It replace the value of the key while composing request URL. Also it can be | ||
// overridden at request level Path Params options, see `Request.SetPathParams`. | ||
func (c *Client) SetPathParams(params map[string]string) *Client { | ||
for p, v := range params { | ||
c.pathParams[p] = v | ||
} | ||
return c | ||
} | ||
|
||
// IsProxySet method returns the true if proxy is set on client otherwise false. | ||
func (c *Client) IsProxySet() bool { | ||
return c.proxyURL != nil | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -354,6 +354,25 @@ func (r *Request) SetDoNotParseResponse(parse bool) *Request { | |
return r | ||
} | ||
|
||
// SetPathParams method sets multiple URL path key-value pairs at one go in the | ||
// resty current request instance. | ||
// resty.R().SetPathParams(map[string]string{ | ||
// "userId": "[email protected]", | ||
// "subAccountId": "100002", | ||
// }) | ||
// | ||
// Result: | ||
// URL - /v1/users/{userId}/{subAccountId}/details | ||
// Composed URL - /v1/users/[email protected]/100002/details | ||
// It replace the value of the key while composing request URL. Also you can | ||
// override Path Params value, which was set at client instance level. | ||
func (r *Request) SetPathParams(params map[string]string) *Request { | ||
for p, v := range params { | ||
r.pathParams[p] = v | ||
} | ||
return r | ||
} | ||
|
||
// ExpectContentType method allows to provide fallback `Content-Type` for automatic unmarshalling | ||
// when `Content-Type` response header is unavailable. | ||
func (r *Request) ExpectContentType(contentType string) *Request { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.