Make RedirectPolicy::redirect() public (#282)

This commit is contained in:
Mattias Päivärinta
2018-04-05 04:07:13 +02:00
committed by Sean McArthur
parent 26e202a0de
commit c00950085c

View File

@@ -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) => {