Function warp::redirect::redirect

source ·
pub fn redirect(uri: impl AsLocation) -> impl Reply
Expand description

HTTP 301 Moved Permanently Description: The requested resource has been permanently moved to a new URL. Usage: It is used when a URL has permanently moved to a new location. Search engines will update their index to the new URL. Browsers and clients will automatically cache this redirect, so subsequent requests for the old URL will automatically go to the new URL without making a request to the old URL. Common Use Case: Changing domain names, restructuring website URLs.

§Example

use warp::{http::Uri, Filter};

let route = warp::path("v1")
    .map(|| {
        warp::redirect(Uri::from_static("/v2"))
    });