summaryrefslogtreecommitdiffstats
path: root/server/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/main.rs')
-rw-r--r--server/src/main.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/server/src/main.rs b/server/src/main.rs
index cc00495..2860531 100644
--- a/server/src/main.rs
+++ b/server/src/main.rs
@@ -175,6 +175,7 @@ async fn run_server() -> Result<(), failure::Error> {
.route("/", web::get().to(handle_home))
.route("/search", web::get().to(handle_search))
.route("/index", web::get().to(handle_search)) // old crates.rs/index url
+ .route("/categories/{rest:.*}", web::get().to(handle_redirect))
.route("/new", web::get().to(handle_new_trending))
.route("/keywords/{keyword}", web::get().to(handle_keyword))
.route("/crates/{crate}", web::get().to(handle_crate))
@@ -358,6 +359,12 @@ async fn handle_gitlab_crate(req: HttpRequest) -> Result<HttpResponse, ServerErr
handle_git_crate(req, "lab").await
}
+async fn handle_redirect(req: HttpRequest) -> HttpResponse {
+ let inf = req.match_info();
+ let rest = inf.query("rest");
+ HttpResponse::PermanentRedirect().header("Location", format!("/{}", rest)).body("")
+}
+
async fn handle_git_crate(req: HttpRequest, slug: &'static str) -> Result<HttpResponse, ServerError> {
let inf = req.match_info();
let state: &AServerState = req.app_data().expect("appdata");