pub struct RedirectBuilder;Implementations§
Source§impl RedirectBuilder
impl RedirectBuilder
Sourcepub fn to(self, path: &str) -> Result<Redirect, AppError>
pub fn to(self, path: &str) -> Result<Redirect, AppError>
Redirects to a literal path.
Fails rather than panics if path can’t be represented as a
Location header value (axum’s own Redirect::to panics on this,
which is unsafe to expose to paths built from request data such as
a ?next= query parameter).
Sourcepub fn route(self, name: &str) -> Result<Redirect, AppError>
pub fn route(self, name: &str) -> Result<Redirect, AppError>
Redirects to a named route (Laravel’s redirect()->route($name)).
Sourcepub fn back(
self,
headers: &HeaderMap,
fallback: &str,
) -> Result<Redirect, AppError>
pub fn back( self, headers: &HeaderMap, fallback: &str, ) -> Result<Redirect, AppError>
Redirects back to wherever the request came from (Laravel’s
redirect()->back()), read from the Referer header - for a
handler that does something (change a preference, submit a small
form) from more than one page and should return the visitor to
whichever one they were actually on, rather than a single
hardcoded destination.
Only the path (plus any query/fragment) is ever taken from
Referer - the scheme and host are discarded unconditionally, so
a header a client fully controls can never redirect anywhere but
this same origin. Falls back to fallback when there’s no
Referer header at all, or it has no path component to extract
(e.g. http://example.test with nothing after the host).
Auto Trait Implementations§
impl Forget for RedirectBuilder
impl Freeze for RedirectBuilder
impl RefUnwindSafe for RedirectBuilder
impl Send for RedirectBuilder
impl Sync for RedirectBuilder
impl Unpin for RedirectBuilder
impl UnsafeUnpin for RedirectBuilder
impl UnwindSafe for RedirectBuilder
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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