pub struct SignedUrls { /* private fields */ }Expand description
Signed URLs for this application’s named routes.
Bound at boot from the same key ring everything else uses, and composed
with the UrlGenerator so a signed link is built from a route name
rather than a path somebody typed twice.
Implementations§
Source§impl SignedUrls
impl SignedUrls
Sourcepub fn new(urls: Arc<UrlGenerator>, signer: Arc<UrlSigner>) -> Self
pub fn new(urls: Arc<UrlGenerator>, signer: Arc<UrlSigner>) -> Self
Sign links to the routes urls knows about.
Sourcepub fn route(&self, name: &str, params: &[(&str, &str)]) -> Result<String>
pub fn route(&self, name: &str, params: &[(&str, &str)]) -> Result<String>
A signed link to a named route.
signed.route("unsubscribe", &[("user", "42")])?
// /unsubscribe/42?signature=…Route parameters are substituted into the path as usual; anything the route does not name becomes a query parameter, and is signed with the rest.
Sourcepub fn temporary_route(
&self,
name: &str,
expires_at: i64,
params: &[(&str, &str)],
) -> Result<String>
pub fn temporary_route( &self, name: &str, expires_at: i64, params: &[(&str, &str)], ) -> Result<String>
A signed link that stops working after expires_at.
expires_at is seconds since the epoch. It is part of the query and so
part of the signature: moving it invalidates the link.
This is the one to reach for. An unsigned expiry is a promise; a signed one is a fact, and a link with no expiry at all lives in a mailbox for years.
Sourcepub fn absolute_route(
&self,
name: &str,
params: &[(&str, &str)],
) -> Result<String>
pub fn absolute_route( &self, name: &str, params: &[(&str, &str)], ) -> Result<String>
A signed absolute URL — with the scheme and host in front.
What goes in an email. Note the host is not covered by the
signature; see UrlSigner.
Sourcepub fn temporary_absolute_route(
&self,
name: &str,
expires_at: i64,
params: &[(&str, &str)],
) -> Result<String>
pub fn temporary_absolute_route( &self, name: &str, expires_at: i64, params: &[(&str, &str)], ) -> Result<String>
absolute_route, expiring.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SignedUrls
impl RefUnwindSafe for SignedUrls
impl Send for SignedUrls
impl Sync for SignedUrls
impl Unpin for SignedUrls
impl UnsafeUnpin for SignedUrls
impl UnwindSafe for SignedUrls
Blanket Implementations§
impl<T> Actor for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Event for T
impl<T> Event for T
Source§fn event_name() -> &'static strwhere
Self: Sized,
fn event_name() -> &'static strwhere
Self: Sized,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more