Merge pull request #137 from budziq/redirect_pub

Exposed RedirectAction and RedirectAttempt
This commit is contained in:
Sean McArthur
2017-06-03 23:01:48 -07:00
committed by GitHub
2 changed files with 7 additions and 3 deletions

View File

@@ -163,7 +163,7 @@ pub use url::ParseError as UrlError;
pub use self::client::{Certificate, Client, ClientBuilder};
pub use self::error::{Error, Result};
pub use self::body::Body;
pub use self::redirect::RedirectPolicy;
pub use self::redirect::{RedirectAction, RedirectAttempt, RedirectPolicy};
pub use self::request::{Request, RequestBuilder};
pub use self::response::Response;

View File

@@ -13,6 +13,8 @@ pub struct RedirectPolicy {
inner: Policy,
}
/// A type that holds information on the next request and previous requests
/// in redirect chain.
#[derive(Debug)]
pub struct RedirectAttempt<'a> {
next: &'a Url,
@@ -51,10 +53,10 @@ impl RedirectPolicy {
/// The custom policy should have some way of handling those.
///
/// Information on the next request and previous requests can be found
/// on the `RedirectAttempt` argument passed to the closure.
/// on the [`RedirectAttempt`] argument passed to the closure.
///
/// Actions can be conveniently created from methods on the
/// `RedirectAttempt`.
/// [`RedirectAttempt`].
///
/// # Example
///
@@ -78,6 +80,8 @@ impl RedirectPolicy {
/// # Ok(())
/// # }
/// ```
///
/// [`RedirectAttempt`]: struct.RedirectAttempt.html
pub fn custom<T>(policy: T) -> RedirectPolicy
where
T: Fn(RedirectAttempt) -> RedirectAction + Send + Sync + 'static,