makes adding loot working

This commit is contained in:
2019-10-07 15:10:35 +02:00
parent 4f6970c423
commit 70eed30bee
8 changed files with 118 additions and 90 deletions

View File

@@ -3,6 +3,7 @@ use actix_files as fs;
use actix_web::{web, App, Error, HttpResponse, HttpServer};
use futures::Future;
use lootalot_db::{DbApi, Pool, QueryResult};
use lootalot_db::models::Item;
use std::env;
use serde::{Serialize, Deserialize};
@@ -162,6 +163,17 @@ pub(crate) fn serve() -> std::io::Result<()> {
db_call(pool, move |api| api.as_admin().resolve_claims())
}),
)
.route(
"/add-loot",
web::post().to_async(
move |pool: AppPool, data: web::Json<Vec<Item>>| {
db_call(pool, move |api| api
.as_admin()
.add_loot(data.to_vec()),
)
}
)
)
.route(
"/add-player",
web::get().to_async(