Enum treemux::RedirectBehavior
source · pub enum RedirectBehavior {
Redirect301,
Redirect307,
Redirect308,
UseHandler,
}
Expand description
Sets the behavior when the router redirects the request to the
canonical version of the requested URL using redirect_trailing_slash
or redirect_clean
.
The default behavior is to return a 301 status, redirecting the browser to the version
of the URL that matches the given pattern.
On a POST request, most browsers that receive a 301 will submit a GET request to
the redirected URL, meaning that any data will likely be lost. If you want to handle
and avoid this behavior, you may use TEMPORARY_REDIRECT
(307), which causes most browsers to
resubmit the request using the original method and request body.
Since 307 is supposed to be a temporary redirect, the new 308 status code has been proposed, which is treated the same, except it indicates correctly that the redirection is permanent. The big caveat here is that the RFC is relatively recent, and older browsers will not know what to do with it. Therefore its use is not recommended unless you really know what you’re doing.
Variants§
Trait Implementations§
source§impl Clone for RedirectBehavior
impl Clone for RedirectBehavior
source§fn clone(&self) -> RedirectBehavior
fn clone(&self) -> RedirectBehavior
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for RedirectBehavior
impl Debug for RedirectBehavior
source§impl Display for RedirectBehavior
impl Display for RedirectBehavior
source§impl PartialEq<RedirectBehavior> for RedirectBehavior
impl PartialEq<RedirectBehavior> for RedirectBehavior
source§fn eq(&self, other: &RedirectBehavior) -> bool
fn eq(&self, other: &RedirectBehavior) -> bool
self
and other
values to be equal, and is used
by ==
.impl Copy for RedirectBehavior
impl Eq for RedirectBehavior
impl StructuralEq for RedirectBehavior
impl StructuralPartialEq for RedirectBehavior
Auto Trait Implementations§
impl RefUnwindSafe for RedirectBehavior
impl Send for RedirectBehavior
impl Sync for RedirectBehavior
impl Unpin for RedirectBehavior
impl UnwindSafe for RedirectBehavior
Blanket Implementations§
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.