0

I want to redirect to an external URL like https://www.google.com, but warp::redirect only only takes a URI and not a URL.

Shepmaster
  • 388,571
  • 95
  • 1,107
  • 1,366

1 Answers1

1

Copying the example from warp::redirect's documentation and running it works fine:

use warp::{http::Uri, Filter}; // 0.2.0
use tokio; // 0.2.9, features = ["full"]

#[tokio::main]
async fn main() {
    let route = warp::any().map(|| warp::redirect(Uri::from_static("https://www.google.com")));

    warp::serve(route).run(([127, 0, 0, 1], 8080)).await;
}
Shepmaster
  • 388,571
  • 95
  • 1,107
  • 1,366