MaxRedirectPolicy specifies the max number of redirect
(noOfRedirect int)
| 13 | |
| 14 | // MaxRedirectPolicy specifies the max number of redirect |
| 15 | func MaxRedirectPolicy(noOfRedirect int) RedirectPolicy { |
| 16 | return func(req *http.Request, via []*http.Request) error { |
| 17 | if len(via) >= noOfRedirect { |
| 18 | return fmt.Errorf("stopped after %d redirects", noOfRedirect) |
| 19 | } |
| 20 | return nil |
| 21 | } |
| 22 | } |
| 23 | |
| 24 | // DefaultRedirectPolicy allows up to 10 redirects |
| 25 | func DefaultRedirectPolicy() RedirectPolicy { |
searching dependent graphs…