Struct salvo_core::writing::Redirect
source · pub struct Redirect { /* private fields */ }
Expand description
Response that redirects the request to another location.
Implementations§
source§impl Redirect
impl Redirect
sourcepub fn other(uri: impl TryInto<Uri>) -> Self
pub fn other(uri: impl TryInto<Uri>) -> Self
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 Uri
.
sourcepub fn temporary(uri: impl TryInto<Uri>) -> Self
pub fn temporary(uri: impl TryInto<Uri>) -> Self
Create a new Redirect
that uses a 307 Temporary Redirect
status code.
§Panics
If uri
isn’t a valid Uri
.
sourcepub fn permanent(uri: impl TryInto<Uri>) -> Self
pub fn permanent(uri: impl TryInto<Uri>) -> Self
Create a new Redirect
that uses a 308 Permanent Redirect
status code.
§Panics
If uri
isn’t a valid Uri
.
sourcepub fn found(uri: impl TryInto<Uri>) -> Self
pub fn found(uri: impl TryInto<Uri>) -> Self
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::other
(303 See Other
) semantics for this
status code. It should be avoided where possible.
§Panics
If uri
isn’t a valid Uri
.
sourcepub fn with_status_code(
status_code: StatusCode,
uri: impl TryInto<Uri>
) -> Result<Self, Error>
pub fn with_status_code( status_code: StatusCode, uri: impl TryInto<Uri> ) -> Result<Self, Error>
Create a new Redirect
that uses a status code.
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 UnwindSafe for Redirect
Blanket Implementations§
source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
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> WithSubscriber for T
impl<T> WithSubscriber for T
source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
source§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
source§impl<P> Writer for P
impl<P> Writer for P
source§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>>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>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
P: 'async_trait,
Response
.