main.rs
use actix_web::{
http::{StatusCode, Method, header},
HttpResponse, Result, Error, HttpServer,
}
fn index() -> Result<HttpResponse, Error> {
let q = "google";
let request_uri = format!("https://www.google.com/search?q={}", q);
Ok(HttpResponse::TemporaryRedirect()
.header(header::LOCATION, request_uri)
.finish()
)
}
fn main() -> std::io::Result<()> {
HttpServer::new(|| App::new().service(
web::resource("/").to(index))
)
.bind("127.0.0.1:8080")?
.run()
}