synthwave/src/route/search.rs

12 lines
312 B
Rust
Raw Normal View History

2024-08-17 08:45:10 +00:00
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"))?))
}