diff --git a/src/xutil/xhttp/options.go b/src/xutil/xhttp/options.go index c5237a5..864e92f 100644 --- a/src/xutil/xhttp/options.go +++ b/src/xutil/xhttp/options.go @@ -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) } diff --git a/src/xutil/xhttp/request.go b/src/xutil/xhttp/request.go index f1bf14e..4fceb73 100644 --- a/src/xutil/xhttp/request.go +++ b/src/xutil/xhttp/request.go @@ -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 @@ -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) {