2017-01-16 22:21:11 -05:00
|
|
|
<?php
|
2017-01-17 22:08:48 -05:00
|
|
|
// Router: handles all REST requests to go to their proper place. Common dependency loading also happens here
|
2017-01-18 21:56:12 -05:00
|
|
|
define('IN_SCRIPT', 1);
|
|
|
|
define('HESK_PATH', '../');
|
|
|
|
require_once(__DIR__ . '/core/common.php');
|
2017-01-25 21:27:39 -05:00
|
|
|
require(__DIR__ . '/Link.php');
|
2017-01-18 21:56:12 -05:00
|
|
|
require(__DIR__ . '/../hesk_settings.inc.php');
|
|
|
|
|
|
|
|
// Controllers
|
|
|
|
require(__DIR__ . '/controllers/CategoryController.php');
|
2017-01-21 22:09:29 -05:00
|
|
|
hesk_load_api_database_functions();
|
2017-01-17 21:58:57 -05:00
|
|
|
|
2017-01-18 21:56:12 -05:00
|
|
|
function handle404() {
|
|
|
|
http_response_code(404);
|
|
|
|
print json_encode('404 found');
|
|
|
|
}
|
|
|
|
|
2017-01-20 07:19:39 -05:00
|
|
|
function assertApiIsEnabled() {
|
|
|
|
//-- TODO
|
|
|
|
}
|
|
|
|
|
2017-01-18 21:56:12 -05:00
|
|
|
// Must use fully-qualified namespace to controllers
|
2017-01-20 07:19:39 -05:00
|
|
|
Link::before('assertApiIsEnabled');
|
|
|
|
|
2017-01-18 17:22:24 -05:00
|
|
|
Link::all(array(
|
2017-01-21 22:09:29 -05:00
|
|
|
// Categories
|
|
|
|
'/v1/categories' => '\Controllers\Category\CategoryController::printAllCategories',
|
|
|
|
'/v1/categories/{i}' => '\Controllers\Category\CategoryController',
|
2017-01-18 21:56:12 -05:00
|
|
|
'404' => 'handle404'
|
2017-01-17 22:12:45 -05:00
|
|
|
));
|