Struct sfo_http::http_server::Redirect
source · pub struct Redirect<T>where
T: AsRef<str>,{ /* private fields */ }Expand description
A redirection endpoint.
Example
async fn route_handler(request: Request<()>) -> tide::Result {
if let Some(product_url) = next_product() {
Ok(Redirect::new(product_url).into())
} else {
//...
}
}Implementations§
source§impl<T> Redirect<T>where
T: AsRef<str>,
impl<T> Redirect<T>where T: AsRef<str>,
sourcepub fn new(location: T) -> Redirect<T>
pub fn new(location: T) -> Redirect<T>
Creates an endpoint that represents a redirect to location.
Uses status code 302 Found.
sourcepub fn permanent(location: T) -> Redirect<T>
pub fn permanent(location: T) -> Redirect<T>
Creates an endpoint that represents a permanent redirect to location.
Uses status code 301 Permanent Redirect.
Trait Implementations§
source§impl<State, T> Endpoint<State> for Redirect<T>where
State: Clone + Send + Sync + 'static,
T: AsRef<str> + Send + Sync + 'static,
impl<State, T> Endpoint<State> for Redirect<T>where State: Clone + Send + Sync + 'static, T: AsRef<str> + Send + Sync + 'static,
Auto Trait Implementations§
impl<T> RefUnwindSafe for Redirect<T>where T: RefUnwindSafe,
impl<T> Send for Redirect<T>where T: Send,
impl<T> Sync for Redirect<T>where T: Sync,
impl<T> Unpin for Redirect<T>where T: Unpin,
impl<T> UnwindSafe for Redirect<T>where T: UnwindSafe,
Blanket Implementations§
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
Mutably borrows from an owned value. Read more