enhance responses from API, integrates with frontend

This commit is contained in:
2019-07-11 14:54:18 +02:00
parent bc65dfcd78
commit e08cd64743
9 changed files with 130 additions and 26 deletions

View File

@@ -85,6 +85,24 @@ pub(crate) fn serve() -> std::io::Result<()> {
db_call(pool, move |api| api.as_player(*player_id).loot())
}),
)
.route(
"/api/{player_id}/claim/{item_id}",
web::get().to_async(move |pool: AppPool, data: web::Path<(i32, i32)>| {
db_call(pool, move |api| api.as_player(data.0).claim(data.1))
})
)
.route(
"/api/{player_id}/unclaim/{item_id}",
web::get().to_async(move |pool: AppPool, data: web::Path<(i32, i32)>| {
db_call(pool, move |api| api.as_player(data.0).unclaim(data.1))
})
)
.route(
"/api/admin/resolve-claims",
web::get().to_async(move |pool: AppPool| {
db_call(pool, move |api| api.as_admin().resolve_claims())
}),
)
.route(
"/api/admin/add-player/{name}/{wealth}",
web::get().to_async(move |pool: AppPool, data: web::Path<(String, f32)>| {