From 09b2d9904175e5d302054cf416c365c388481c91 Mon Sep 17 00:00:00 2001 From: liujian Date: Wed, 27 Sep 2023 16:37:13 +0800 Subject: [PATCH] Update xhttp options --- src/xutil/xhttp/options.go | 4 ++-- src/xutil/xhttp/request.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) 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) {