Can now get maps by mapper or category.
This commit is contained in:
parent
c277eb5ebd
commit
c3fa0f0202
|
@ -10,6 +10,28 @@ async fn get_all_maps(db: &State<DatabaseHandler>) -> Result<Json<Vec<Map>>, Str
|
|||
}
|
||||
}
|
||||
|
||||
pub fn get_all_routes() -> Vec<Route> {
|
||||
routes![get_all_maps]
|
||||
#[get("/category/<category>")]
|
||||
async fn get_maps_by_category(
|
||||
db: &State<DatabaseHandler>,
|
||||
category: &str,
|
||||
) -> Result<Json<Vec<Map>>, String> {
|
||||
match Map::get_maps_by_category(db, category).await {
|
||||
Ok(maps) => Ok(Json(maps)),
|
||||
Err(err) => Err(format!("Error: {}", err)),
|
||||
}
|
||||
}
|
||||
|
||||
#[get("/mapper/<mapper>")]
|
||||
async fn get_maps_by_mapper(
|
||||
db: &State<DatabaseHandler>,
|
||||
mapper: &str,
|
||||
) -> Result<Json<Vec<Map>>, String> {
|
||||
match Map::get_maps_by_category(db, mapper).await {
|
||||
Ok(maps) => Ok(Json(maps)),
|
||||
Err(err) => Err(format!("Error: {}", err)),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_all_routes() -> Vec<Route> {
|
||||
routes![get_all_maps, get_maps_by_category, get_maps_by_mapper]
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user