fixes some misbehaviour

This commit is contained in:
2019-11-07 15:55:58 +01:00
parent 4925afbeb5
commit 1cc9c2eefa
6 changed files with 94 additions and 30 deletions

View File

@@ -10,6 +10,7 @@ use crate::api;
type AppPool = web::Data<db::Pool>;
type PlayerId = web::Path<i32>;
type ItemId = web::Json<i32>;
type IdList = web::Json<api::IdList>;
#[derive(Serialize, Deserialize, Debug)]
struct NewGroupLoot {
@@ -66,6 +67,12 @@ fn configure_api(config: &mut web::ServiceConfig) {
.service(
web::resource("/claims")
//.route(web::get().to_async(endpoints::player_claims))
.route(web::post().to_async(
|pool, (player, data): (PlayerId, IdList)|
{
db_call(pool, Q::ClaimItems(*player, data.clone()))
}
))
.route(web::put().to_async(
|pool, (player, data): (PlayerId, ItemId)| {
db_call(pool, Q::ClaimItem(*player, *data))
@@ -142,7 +149,7 @@ pub fn serve() -> std::io::Result<()> {
.configure(configure_api)
.wrap(
Cors::new()
.allowed_origin("http://localhost:8080")
.allowed_origin("http://localhost:8088")
.allowed_methods(vec!["GET", "POST", "PUT", "DELETE", "OPTIONS"])
.max_age(3600),
)