Created API for API requests
This commit is contained in:
@@ -24,6 +24,7 @@ if (Core\Session::exists('info')) {
|
||||
}
|
||||
|
||||
$router = new Core\Router();
|
||||
$routerapi = new Core\RouterApi();
|
||||
|
||||
$router->add('', ['controller' => 'posts', 'action' => 'index']);
|
||||
$router->add('{controller}/{action}');
|
||||
@@ -31,5 +32,10 @@ $router->add('{controller}/{action}/{id:\d+}');
|
||||
$router->add('{action}', ['controller' => 'home']);
|
||||
$router->add('{?status:\d+}', ['controller' => 'posts', 'action' => 'index']);
|
||||
|
||||
$routerapi->add('api', ['action' => 'index']);
|
||||
$routerapi->add('api/{model}');
|
||||
$routerapi->add('api/{model}/{id:\d+}');
|
||||
|
||||
$url = $_SERVER['REQUEST_URI'];
|
||||
$router->dispatch($url);
|
||||
if ($routerapi->match($url)) { $routerapi->dispatchApi($url); }
|
||||
else { $router->dispatch($url); }
|
||||
|
||||
Reference in New Issue
Block a user