File tree Expand file tree Collapse file tree 1 file changed +15
-12
lines changed Expand file tree Collapse file tree 1 file changed +15
-12
lines changed Original file line number Diff line number Diff line change @@ -71,24 +71,27 @@ func defaultOpts() *RetryOpts {
71
71
return opts
72
72
}
73
73
74
- func Retry (opts RetryOpts ) func (http.RoundTripper ) http.RoundTripper {
74
+ func Retry (opts ... RetryOpts ) func (http.RoundTripper ) http.RoundTripper {
75
75
76
76
retryOpts := defaultOpts ()
77
77
78
- if opts .MaxRetries > 0 {
79
- retryOpts .MaxRetries = opts .MaxRetries
80
- }
78
+ // overwrite defaults
79
+ if len (opts ) > 0 {
80
+ if opts [0 ].MaxRetries > 0 {
81
+ retryOpts .MaxRetries = opts [0 ].MaxRetries
82
+ }
81
83
82
- if opts .Codes != nil {
83
- retryOpts .Codes = opts .Codes [:]
84
- }
84
+ if opts [ 0 ] .Codes != nil {
85
+ retryOpts .Codes = opts [ 0 ] .Codes [:]
86
+ }
85
87
86
- if opts .BaseDelay > 0 {
87
- retryOpts .BaseDelay = opts .BaseDelay
88
- }
88
+ if opts [ 0 ] .BaseDelay > 0 {
89
+ retryOpts .BaseDelay = opts [ 0 ] .BaseDelay
90
+ }
89
91
90
- if opts .Cb != nil {
91
- retryOpts .Cb = opts .Cb
92
+ if opts [0 ].Cb != nil {
93
+ retryOpts .Cb = opts [0 ].Cb
94
+ }
92
95
}
93
96
94
97
return func (next http.RoundTripper ) http.RoundTripper {
You can’t perform that action at this time.
0 commit comments