Skip to content

Commit

Permalink
create Lobby API Test
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashikkalis committed Jan 10, 2025
1 parent 72cee45 commit 975da48
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion blokus.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,15 @@
$router->add('GET', 'lobbys', 'getLobbies');
$router->add('GET', 'lobbys/{id}', 'getLobby');

$router->add('POST', 'lobbys/create/{hostId}','createGame' );
$router->add('POST', 'lobbys/create', function($input) {
if (!isset($input['hostId'])) {
echo json_encode(['error' => 'Missing required parameters: hostId']);
return;
}
$hostId = (int)$input['hostId'];

createGame($hostId);
});


$router->add('POST', 'lobbys/leave', function($input) {
Expand Down
2 changes: 1 addition & 1 deletion lib/lobbys.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function getLobby($lobby_id) {
}
}

//===============UNKNOWN===============
//===============IN PROGGRESS===============
function createGame($host_id) {
$pdo = getDatabaseConnection();
try {
Expand Down

0 comments on commit 975da48

Please sign in to comment.