pub struct Redirect { /* private fields */ }
Expand description
Response that redirects the request to another location.
Implementations
sourceimpl Redirect
impl Redirect
sourcepub fn other(uri: impl TryInto<Uri>) -> Result<Redirect, Error>
pub fn other(uri: impl TryInto<Uri>) -> Result<Redirect, Error>
Create a new Redirect
that uses a 303 See Other
status 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).
Panics
If uri
isn’t a valid HeaderValue
.
sourcepub fn temporary(uri: impl TryInto<Uri>) -> Result<Redirect, Error>
pub fn temporary(uri: impl TryInto<Uri>) -> Result<Redirect, Error>
Create a new Redirect
that uses a 307 Temporary Redirect
status code.
This has the same behavior as [Redirect::to
], except it will preserve the original HTTP
method and body.
Panics
If uri
isn’t a valid HeaderValue
.
sourcepub fn permanent(uri: impl TryInto<Uri>) -> Result<Redirect, Error>
pub fn permanent(uri: impl TryInto<Uri>) -> Result<Redirect, Error>
Create a new Redirect
that uses a 308 Permanent Redirect
status code.
Panics
If uri
isn’t a valid HeaderValue
.
sourcepub fn found(uri: impl TryInto<Uri>) -> Result<Redirect, Error>
pub fn found(uri: impl TryInto<Uri>) -> Result<Redirect, Error>
Create a new Redirect
that uses a 302 Found
status code.
This is the same as Redirect::temporary
, except the status code is older and thus
supported by some legacy applications that doesn’t understand the newer one, but some of
those applications wrongly apply [Redirect::to
] (303 See Other
) semantics for this
status code. It should be avoided where possible.
Panics
If uri
isn’t a valid HeaderValue
.
sourcepub fn with_status_code(
status_code: StatusCode,
uri: impl TryInto<Uri>
) -> Result<Redirect, Error>
pub fn with_status_code(
status_code: StatusCode,
uri: impl TryInto<Uri>
) -> Result<Redirect, Error>
Create a new Redirect
that uses a status code.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Redirect
impl Send for Redirect
impl Sync for Redirect
impl Unpin for Redirect
impl UnwindSafe for Redirect
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<V, T> VZip<V> for Twhere
V: MultiLane<T>,
impl<V, T> VZip<V> for Twhere
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourceimpl<P> Writer for Pwhere
P: Piece + Send,
impl<P> Writer for Pwhere
P: Piece + Send,
sourcefn write<'life0, 'life1, 'life2, 'async_trait>(
self,
_req: &'life0 mut Request,
_depot: &'life1 mut Depot,
res: &'life2 mut Response
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
P: 'async_trait,
fn write<'life0, 'life1, 'life2, 'async_trait>(
self,
_req: &'life0 mut Request,
_depot: &'life1 mut Depot,
res: &'life2 mut Response
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
P: 'async_trait,
Write data to Response
.