Make RedirectPolicy::redirect() public (#282)
This commit is contained in:
committed by
Sean McArthur
parent
26e202a0de
commit
c00950085c
@@ -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 {
|
match self.inner {
|
||||||
Policy::Custom(ref custom) => custom(attempt),
|
Policy::Custom(ref custom) => custom(attempt),
|
||||||
Policy::Limit(max) => {
|
Policy::Limit(max) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user