From c00950085cef12670404731a107f304214220347 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20P=C3=A4iv=C3=A4rinta?= Date: Thu, 5 Apr 2018 04:07:13 +0200 Subject: [PATCH] Make RedirectPolicy::redirect() public (#282) --- src/redirect.rs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) 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) => {