pub struct Redirect { /* private fields */ }Expand description
Response that redirects the request to another location.
§Example
use salvo_core::prelude::*;
#[handler]
async fn hello(res: &mut Response) {
res.render(Redirect::found("https://www.rust-lang.org/"))
}Implementations§
Source§impl Redirect
impl Redirect
Sourcepub fn other(uri: impl TryInto<Uri>) -> Redirect
pub fn other(uri: impl TryInto<Uri>) -> Redirect
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>) -> Redirect
pub fn temporary(uri: impl TryInto<Uri>) -> Redirect
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>) -> Redirect
pub fn permanent(uri: impl TryInto<Uri>) -> Redirect
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>) -> Redirect
pub fn found(uri: impl TryInto<Uri>) -> Redirect
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<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 !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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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> Pointable for T
impl<T> Pointable for T
Source§impl<Key, T> QuotaGetter<Key> for T
impl<Key, T> QuotaGetter<Key> for T
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.