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