Struct Redirect
#[must_use = "needs to be returned from a handler or otherwise turned into a Response to be useful"]
pub struct Redirect { /* private fields */ }
Response that redirects the request to another location.
Example
use ;
let app = new
.route
.route;
# let _: Router = app;
Implementations
impl Redirect
fn to(uri: &str) -> SelfCreate a new
Redirectthat uses a303 See Otherstatus code.This redirect instructs the client to change the method to GET for the subsequent request to the given
uri, which is useful after successful form submission, file upload or when you generally don't want the redirected-to page to observe the original request method and body (if non-empty). If you want to preserve the request method and body,Redirect::temporaryshould be used instead.fn temporary(uri: &str) -> SelfCreate a new
Redirectthat uses a307 Temporary Redirectstatus code.This has the same behavior as
Redirect::to, except it will preserve the original HTTP method and body.fn permanent(uri: &str) -> SelfCreate a new
Redirectthat uses a308 Permanent Redirectstatus code.fn status_code(&self) -> StatusCodeReturns the HTTP status code of the
Redirect.fn location(&self) -> &strReturns the
Redirect's URI.
Trait Implementations
impl Clone for Redirect
fn clone(&self) -> Redirect
impl Debug for Redirect
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl IntoResponse for Redirect
fn into_response(self) -> Response
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
impl<H, T> HandlerWithoutStateExt<T> for Redirect
where
H: Handler<T, ()>,
fn into_service(self) -> HandlerService<H, T, ()>fn into_make_service(self) -> IntoMakeService<HandlerService<H, T, ()>>fn into_make_service_with_connect_info<C>(self) -> IntoMakeServiceWithConnectInfo<HandlerService<H, T, ()>, C>
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for Redirect
where
ST: ?Sized,
DT: ?Sized,
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for Redirect
where
ST: ?Sized,
DT: ?Sized,
impl<T> Any for Redirect
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for Redirect
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for Redirect
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> CloneToUninit for Redirect
where
T: Clone,
unsafe fn clone_to_uninit(&self, dest: *mut u8)
impl<T> From<T> for Redirect
fn from(t: T) -> TReturns the argument unchanged.
impl<T> FromRef<T> for Redirect
where
T: Clone,
fn from_ref(input: &T) -> T
impl<T> Instrument for Redirect
impl<T> Read<Exclusive, BecauseExclusive> for Redirect
where
T: ?Sized,
impl<T> Same for Redirect
type Output = T;
impl<T> ToOwned for Redirect
where
T: Clone,
type Owned = T;fn to_owned(&self) -> Tfn clone_into(&self, target: &mut T)
impl<T> WithSubscriber for Redirect
impl<T, U> Into<U> for Redirect
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for Redirect
where
U: Into<T>,
type Error = never;fn try_from(value: U) -> Result<T, never>
impl<T, U> TryInto<U> for Redirect
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
impl<V, T> VZip<V> for Redirect
where
V: MultiLane<T>,
fn vzip(self) -> V