Skip to content

Commit

Permalink
Update xhttp options
Browse files Browse the repository at this point in the history
  • Loading branch information
onanying committed Sep 27, 2023
1 parent 776564b commit 09b2d99
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/xutil/xhttp/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ type requestOptions struct {
RetryOptions []retry.Option
}

func getOptions(opts []RequestOption) *requestOptions {
opt := DefaultOptions
func mergeOptions(opts []RequestOption) *requestOptions {
opt := DefaultOptions // copy
for _, o := range opts {
o.apply(&opt)
}
Expand Down
4 changes: 2 additions & 2 deletions src/xutil/xhttp/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func newResponse(r *http.Response) *Response {
}

func Request(method string, u string, opts ...RequestOption) (*Response, error) {
opt := getOptions(opts)
opt := mergeOptions(opts)
URL, err := url.Parse(u)
if err != nil {
return nil, err
Expand All @@ -60,7 +60,7 @@ func Request(method string, u string, opts ...RequestOption) (*Response, error)
}

func Do(req *http.Request, opts ...RequestOption) (*Response, error) {
opt := getOptions(opts)
opt := mergeOptions(opts)

if opt.RetryOptions != nil {
return doRetry(opt, func() (*Response, error) {
Expand Down

0 comments on commit 09b2d99

Please sign in to comment.