Added search endpoints
This commit is contained in:
parent
91919a6628
commit
cabc72116a
1 changed files with 14 additions and 0 deletions
|
@ -29,6 +29,8 @@ pub fn get_routes() -> Vec<rocket::Route> {
|
|||
flatten,
|
||||
random,
|
||||
recent,
|
||||
search_root,
|
||||
search,
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -202,3 +204,15 @@ fn recent(db: State<DB>, _auth: Auth) -> Result<(Json<Vec<index::Directory>>), e
|
|||
let result = index::get_recent_albums::<DB>(&db, 20)?;
|
||||
Ok(Json(result))
|
||||
}
|
||||
|
||||
#[get("/search")]
|
||||
fn search_root(db: State<DB>, _auth: Auth) -> Result<(Json<Vec<index::CollectionFile>>), errors::Error> {
|
||||
let result = index::search::<DB>(&db, "")?;
|
||||
Ok(Json(result))
|
||||
}
|
||||
|
||||
#[get("/search/<query>")]
|
||||
fn search(db: State<DB>, _auth: Auth, query: String) -> Result<(Json<Vec<index::CollectionFile>>), errors::Error> {
|
||||
let result = index::search::<DB>(&db, &query)?;
|
||||
Ok(Json(result))
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue