learning how to test
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
use std::env;
|
||||
use futures::Future;
|
||||
use actix_files as fs;
|
||||
use actix_web::{web, App, HttpServer, HttpResponse, Error};
|
||||
use actix_cors::Cors;
|
||||
use lootalot_db::{Pool, DbApi, QueryResult};
|
||||
use actix_files as fs;
|
||||
use actix_web::{web, App, Error, HttpResponse, HttpServer};
|
||||
use futures::Future;
|
||||
use lootalot_db::{DbApi, Pool, QueryResult};
|
||||
use std::env;
|
||||
|
||||
type AppPool = web::Data<Pool>;
|
||||
|
||||
@@ -61,17 +61,17 @@ pub(crate) fn serve() -> std::io::Result<()> {
|
||||
Cors::new()
|
||||
.allowed_origin("http://localhost:8080")
|
||||
.allowed_methods(vec!["GET", "POST"])
|
||||
.max_age(3600)
|
||||
.max_age(3600),
|
||||
)
|
||||
.route(
|
||||
"/api/players",
|
||||
web::get().to_async(move |pool: AppPool| {
|
||||
db_call(pool, move |api| api.fetch_players())
|
||||
}),
|
||||
web::get()
|
||||
.to_async(move |pool: AppPool| db_call(pool, move |api| api.fetch_players())),
|
||||
)
|
||||
.route(
|
||||
"/api/claims",
|
||||
web::get().to_async(move |pool: AppPool| db_call(pool, move |api| api.fetch_claims())),
|
||||
web::get()
|
||||
.to_async(move |pool: AppPool| db_call(pool, move |api| api.fetch_claims())),
|
||||
)
|
||||
.route(
|
||||
"/api/{player_id}/update-wealth/{amount}",
|
||||
@@ -89,13 +89,13 @@ pub(crate) fn serve() -> std::io::Result<()> {
|
||||
"/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",
|
||||
@@ -106,7 +106,9 @@ pub(crate) fn serve() -> std::io::Result<()> {
|
||||
.route(
|
||||
"/api/admin/add-player/{name}/{wealth}",
|
||||
web::get().to_async(move |pool: AppPool, data: web::Path<(String, f32)>| {
|
||||
db_call(pool, move |api| api.as_admin().add_player(data.0.clone(), data.1))
|
||||
db_call(pool, move |api| {
|
||||
api.as_admin().add_player(data.0.clone(), data.1)
|
||||
})
|
||||
}),
|
||||
)
|
||||
.service(fs::Files::new("/", www_root.clone()).index_file("index.html"))
|
||||
|
||||
Reference in New Issue
Block a user