search
This commit is contained in:
parent
7e6b65392e
commit
66b2a959d7
5 changed files with 157 additions and 2 deletions
|
@ -10,6 +10,7 @@ pub mod album;
|
|||
pub mod artist;
|
||||
pub mod event;
|
||||
pub mod playlist;
|
||||
pub mod search;
|
||||
pub mod track;
|
||||
pub mod user;
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ use super::ToAPI;
|
|||
#[get("/playlists")]
|
||||
pub async fn playlists_route(u: User) -> FallibleApiResponse {
|
||||
let mut playlists = vec![
|
||||
json!({"id": "recent", "name": "Recently Played"}),
|
||||
json!({"id": "recents", "name": "Recently Played"}),
|
||||
json!({"id": "recentlyAdded", "name": "Recently Added"}),
|
||||
];
|
||||
|
||||
|
|
12
src/route/search.rs
Normal file
12
src/route/search.rs
Normal file
|
@ -0,0 +1,12 @@
|
|||
use super::api_error;
|
||||
use super::FallibleApiResponse;
|
||||
use mongodb::bson::doc;
|
||||
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"))?))
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue