synthwave/src/route/search.rs
2024-10-04 14:46:06 +02:00

11 lines
312 B
Rust

use super::api_error;
use super::FallibleApiResponse;
use rocket::get;
use serde_json::json;
#[get("/search?<query>")]
pub async fn search_route(query: String) -> FallibleApiResponse {
Ok(json!(crate::library::search::search_for(query)
.await
.ok_or_else(|| api_error("Search failed"))?))
}