Refactorings/fixes for back-end
This commit is contained in:
parent
e1180963f3
commit
97ca4adecc
2 changed files with 3 additions and 13 deletions
|
@ -10,9 +10,7 @@ pub fn handle_json(root: Value) -> Result<String, String> {
|
|||
"disconnect" => handle_disconnect(root),
|
||||
"request_board_state" => handle_request_board_state(root),
|
||||
"game_state" => handle_game_state(root),
|
||||
_ => {
|
||||
Err("{\"type\":\"invalid_type\"}".into())
|
||||
}
|
||||
_ => Err("{\"type\":\"invalid_type\"}".into()),
|
||||
}
|
||||
} else {
|
||||
Err("{\"type\":\"invalid_json\"}".into())
|
||||
|
|
|
@ -9,16 +9,8 @@ async fn main() {
|
|||
.and(warp::body::json())
|
||||
.map(|json_value: Value| {
|
||||
let result = json_handlers::handle_json(json_value);
|
||||
if let Ok(result_str) = result {
|
||||
result_str
|
||||
} else if let Err(error_str) = result {
|
||||
error_str
|
||||
} else {
|
||||
unreachable!()
|
||||
}
|
||||
result.unwrap_or_else(|e| e)
|
||||
});
|
||||
|
||||
warp::serve(route)
|
||||
.run(([0,0,0,0], 1237))
|
||||
.await;
|
||||
warp::serve(route).run(([0, 0, 0, 0], 1237)).await;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue