From 18f64358f01e8b233dd663a475f4c5de61c09259 Mon Sep 17 00:00:00 2001 From: ElnuDev Date: Sat, 12 Aug 2023 13:58:11 -0700 Subject: [PATCH] images: remove /search route prefix --- images/src/main.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/images/src/main.rs b/images/src/main.rs index 268f72b..c91ca54 100644 --- a/images/src/main.rs +++ b/images/src/main.rs @@ -43,7 +43,7 @@ where }) } -#[get("/search/{query}/list")] +#[get("/{query}/list")] async fn route_query_list(path: web::Path) -> Result { let query = path.into_inner(); let images = get_images(&query).await?; @@ -52,19 +52,19 @@ async fn route_query_list(path: web::Path) -> Result { .body(serde_json::to_string(&images).unwrap_or_else(|_| "[]".to_string()))) } -#[get("/search/{query}")] +#[get("/{query}")] async fn route_query(path: web::Path) -> Result { let query = path.into_inner(); route(&query, |images| images.get(0)).await } -#[get("/search/{query}/random")] +#[get("/{query}/random")] async fn route_query_random(path: web::Path) -> Result { let query = path.into_inner(); route(&query, |images| images.choose(&mut rand::thread_rng())).await } -#[get("/search/{query}/{index}")] +#[get("/{query}/{index}")] async fn route_query_index(path: web::Path<(String, usize)>) -> Result { let (query, index) = path.into_inner(); route(&query, move |images| images.get(index % images.len())).await