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.
Asked
Active
Viewed 1,042 times
0

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

user1960372
- 11
- 1
-
1URLs are a subset of URIs – Nihar Karve Jan 21 '20 at 05:48
1 Answers
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