You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

111 lines
4.2 KiB

<?php namespace Config;
use App\Controllers\GameController;
/**
* --------------------------------------------------------------------
* URI Routing
* --------------------------------------------------------------------
* This file lets you re-map URI requests to specific controller functions.
*
* Typically there is a one-to-one relationship between a URL string
* and its corresponding controller class/method. The segments in a
* URL normally follow this pattern:
*
* example.com/class/method/id
*
* In some instances, however, you may want to remap this relationship
* so that a different class/function is called than the one
* corresponding to the URL.
*/
// Create a new instance of our RouteCollection class.
$routes = Services::routes(true);
// Load the system's routing file first, so that the app and ENVIRONMENT
// can override as needed.
if (file_exists(SYSTEMPATH . 'Config/Routes.php'))
{
require SYSTEMPATH . 'Config/Routes.php';
}
/**
* --------------------------------------------------------------------
* Router Setup
* --------------------------------------------------------------------
* The RouteCollection object allows you to modify the way that the
* Router works, by acting as a holder for it's configuration settings.
* The following methods can be called on the object to modify
* the default operations.
*
* $routes->defaultNamespace()
*
* Modifies the namespace that is added to a controller if it doesn't
* already have one. By default this is the global namespace (\).
*
* $routes->defaultController()
*
* Changes the name of the class used as a controller when the route
* points to a folder instead of a class.
*
* $routes->defaultMethod()
*
* Assigns the method inside the controller that is ran when the
* Router is unable to determine the appropriate method to run.
*
* $routes->setAutoRoute()
*
* Determines whether the Router will attempt to match URIs to
* Controllers when no specific route has been defined. If false,
* only routes that have been defined here will be available.
*/
$routes->setDefaultNamespace('App\Controllers');
$routes->setDefaultController('GameController');
$routes->setDefaultMethod('index');
$routes->setTranslateURIDashes(false);
$routes->set404Override();
$routes->setAutoRoute(true);
/**
* --------------------------------------------------------------------
* Route Definitions
* --------------------------------------------------------------------
*/
// We get a performance increase by specifying the default
// route since we don't have to scan directories.
$routes->get('/', 'GameController::index');
/**
* --------------------------------------------------------------------
* GAME ROUTES
* --------------------------------------------------------------------
*/
$routes->add('createUser', 'GameController::createUser');
$routes->add('createUser/(:segment)/(:segment)', 'GameController::createUser/$1/$2');
$routes->add('endGame', 'GameController::endGame');
$routes->add('getUser', 'GameController::getUser');
$routes->add('getUser/(:segment)', 'GameController::getUser/$1');
$routes->add('play', 'GameController::play');
$routes->add('play/(:segment)', 'GameController::play/$1');
$routes->add('setup', 'SetupController::setup');
//$routes->add('testUser', 'GameController::testUser');
$routes->add('testUser/(:segment)', 'GameController::testUser/$1');
$routes->add('top10', 'GameController::top10');
/**
* --------------------------------------------------------------------
* Additional Routing
* --------------------------------------------------------------------
*
* There will often be times that you need additional routing and you
* need to it be able to override any defaults in this file. Environment
* based routes is one such time. require() additional route files here
* to make that happen.
*
* You will have access to the $routes object within that file without
* needing to reload it.
*/
if (file_exists(APPPATH . 'Config/' . ENVIRONMENT . '/Routes.php'))
{
require APPPATH . 'Config/' . ENVIRONMENT . '/Routes.php';
}