Commit 665ebcd6 authored by marisa's avatar marisa

fmt

parent 5bd95da6
......@@ -3,7 +3,10 @@ use actix_web::{http::header, http::Method, server, App, HttpRequest, HttpRespon
fn normal_crate(req: HttpRequest) -> HttpResponse {
let cratename: String = req.match_info().query("crate").unwrap();
HttpResponse::PermanentRedirect()
.header(header::LOCATION, format!("https://crates.io/crates/{}", cratename))
.header(
header::LOCATION,
format!("https://crates.io/crates/{}", cratename),
)
.finish()
}
......@@ -15,10 +18,12 @@ fn docs_rs(req: HttpRequest) -> HttpResponse {
}
fn main() {
server::new(|| App::new()
.route("/d/{crate:.*}", Method::GET, docs_rs)
.route("/{crate:.*}", Method::GET, normal_crate))
.bind("127.0.0.1:8080")
.unwrap()
.run();
}
\ No newline at end of file
server::new(|| {
App::new()
.route("/d/{crate:.*}", Method::GET, docs_rs)
.route("/{crate:.*}", Method::GET, normal_crate)
})
.bind("127.0.0.1:8080")
.unwrap()
.run();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment