diff --git a/src/redirect.rs b/src/redirect.rs index 273ff04..4c8f290 100644 --- a/src/redirect.rs +++ b/src/redirect.rs @@ -91,7 +91,27 @@ impl RedirectPolicy { } } - fn redirect(&self, attempt: RedirectAttempt) -> RedirectAction { + /// Apply this policy to a given [`RedirectAttempt`] to produce a [`RedirectAction`]. + /// + /// # Note + /// + /// This method can be used together with RedirectPolicy::custom() + /// to construct one RedirectPolicy that wraps another. + /// + /// # Example + /// + /// ```rust + /// # use reqwest::{Error, RedirectPolicy}; + /// # + /// # fn run() -> Result<(), Error> { + /// let custom = RedirectPolicy::custom(|attempt| { + /// eprintln!("Location: {:?}", attempt.url()); + /// RedirectPolicy::default().redirect(attempt) + /// }); + /// # Ok(()) + /// # } + /// ``` + pub fn redirect(&self, attempt: RedirectAttempt) -> RedirectAction { match self.inner { Policy::Custom(ref custom) => custom(attempt), Policy::Limit(max) => {