From b19d56fd9a9a3dae8e97560d75dfd5b44b0ad91c Mon Sep 17 00:00:00 2001 From: Artus Date: Sun, 15 Dec 2019 16:02:00 +0100 Subject: [PATCH] updates for prod env --- src/api.rs | 13 +------------ src/server.rs | 19 ++++--------------- 2 files changed, 5 insertions(+), 27 deletions(-) diff --git a/src/api.rs b/src/api.rs index 04a593d..0516d23 100644 --- a/src/api.rs +++ b/src/api.rs @@ -16,6 +16,7 @@ pub struct BuySellParams { #[derive(Serialize, Deserialize, Debug)] pub struct NewGroupLoot { source_name: String, + // claims_limit_date: String pub items: ItemList, } @@ -80,8 +81,6 @@ pub enum ApiActions { BuyItems(i32, BuySellParams), SellItems(i32, BuySellParams), ClaimItems(i32, IdList), - ClaimItem(i32, i32), - UnclaimItem(i32, i32), UndoLastAction(i32), // Group level AddLoot(NewGroupLoot), @@ -235,16 +234,6 @@ pub fn execute( Ok(Some((id, "Vente d'objets"))) })? } - ApiActions::ClaimItem(id, item) => { - response.push_update(db::Claims(conn).add(id, item)?); - response.notify("Pour moi !".to_string()); - None - } - ApiActions::UnclaimItem(id, item) => { - response.push_update(db::Claims(conn).remove(id, item)?); - response.notify("Bof! Finalement non.".to_string()); - None - } ApiActions::ClaimItems(id, items) => { conn.transaction(|| -> Result, diesel::result::Error> { let current_claims: HashSet = db::Claims(conn) diff --git a/src/server.rs b/src/server.rs index 8097f7a..ca37080 100644 --- a/src/server.rs +++ b/src/server.rs @@ -136,16 +136,6 @@ fn configure_api(config: &mut web::ServiceConfig) { db_call(pool, Q::ClaimItems(*player, data.into_inner())) }, )) - .route(web::put().to_async( - |pool, (player, data): (PlayerId, ItemId)| { - db_call(pool, Q::ClaimItem(*player, *data)) - }, - )) - .route(web::delete().to_async( - |pool, (player, data): (PlayerId, ItemId)| { - db_call(pool, Q::UnclaimItem(*player, *data)) - }, - )), ) .service( web::resource("/wealth") @@ -294,12 +284,11 @@ fn enter_session(id: Identity, pool: AppPool) -> impl Future std::io::Result<()> { - let www_root: String = env::var("WWW_ROOT").expect("WWW_ROOT must be set"); + let domain: String = env::var("DOMAIN").expect("DOMAIN must be set"); let pool = db::create_pool(); - dbg!(&www_root); + println!("Serving Loot-a-lot on {}", domain); let key = [0; 32]; // TODO: Use a real key - let domain = "http://localhost:8088"; HttpServer::new(move || { App::new() @@ -307,7 +296,7 @@ pub fn serve() -> std::io::Result<()> { .configure(configure_api) .wrap( Cors::new() - .allowed_origin(domain) + .allowed_origin(&domain) .allowed_methods(vec!["GET", "POST", "PUT", "DELETE", "OPTIONS"]) .max_age(3600), ) @@ -321,7 +310,7 @@ pub fn serve() -> std::io::Result<()> { .route("/session", web::get().to_async(enter_session)) .route("/login", web::get().to(login)) .route("/logout", web::get().to(logout)) - .service(fs::Files::new("/", www_root.clone()).index_file("index.html")) + //.service(fs::Files::new("/", www_root.clone()).index_file("index.html")) }) .bind("127.0.0.1:8088")? .run()