pub struct Redirect { /* private fields */ }Expand description
HTTP Redirect response builder
Implementations§
Source§impl Redirect
impl Redirect
Sourcepub fn back(req: &Request, fallback: impl Into<String>) -> Self
pub fn back(req: &Request, fallback: impl Into<String>) -> Self
Create a redirect that returns the user to the page that triggered
the current request, derived from the Referer header.
Preserves query string and fragment from the source page so tab
selection (?tab=note), pagination cursors, and scroll-restoration
keys (scroll_preserve.rs) survive form POSTs.
Falls back to fallback when the Referer is absent or points
off-origin. Same-origin is enforced by requiring the Referer’s host
to match the request’s Host header (or the Referer to be already
a relative path) — protects against open-redirect via spoofed Referer.
Sourcepub fn route(name: &str) -> RedirectRouteBuilder
pub fn route(name: &str) -> RedirectRouteBuilder
Create a redirect to a named route
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Redirect
impl RefUnwindSafe for Redirect
impl Send for Redirect
impl Sync for Redirect
impl Unpin for Redirect
impl UnsafeUnpin for Redirect
impl UnwindSafe for Redirect
Blanket Implementations§
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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