PHP_SMART_HOME_V3/app/Routes.php

67 lines
2.1 KiB
PHP
Raw Normal View History

2020-05-16 17:18:27 +02:00
<?php
$router = new Router();
$router->setDefault(function(){
echo $_GET['url'].': 404';
2020-07-28 15:51:40 +02:00
$logManager = new LogManager();
$logManager->setLevel(LOGLEVEL);
$logManager->write("[ROUTER]" . $_GET['url'] . "not found", LogRecordTypes::WARNING);
unset($logManager);
2020-05-16 17:18:27 +02:00
});
//Pages
2020-07-23 17:29:55 +02:00
$router->any('/', 'Log');
2020-07-23 15:16:44 +02:00
$router->any('/log', 'Log');
2020-07-23 17:58:46 +02:00
$router->any('/server', 'Server');
2020-05-16 17:18:27 +02:00
$router->any('/login', 'Login');
$router->any('/logout', 'Logout');
$router->any('/automation', 'Automation');
$router->any('/setting', 'Setting');
2020-08-31 21:23:23 +02:00
$router->any('/device', 'Device');
$router->any('/device/{sortBy}/{sortType}', 'Device');
2020-10-26 00:01:30 +01:00
$router->any('/plugins', 'Plugins');
2020-05-16 17:18:27 +02:00
$router->any('/ajax', 'Ajax');
2020-05-17 01:27:06 +02:00
$router->any('/oauth', 'Oauth');
2020-05-16 17:18:27 +02:00
2020-07-14 18:24:21 +02:00
//Vue APP
2020-05-16 17:18:27 +02:00
$router->post('/api/login', 'AuthApi@login');
$router->post('/api/logout', 'AuthApi@logout');
$router->get('/api/rooms', 'RoomsApi@default');
2020-05-24 19:40:49 +02:00
$router->get('/api/rooms/{roomId}/update', 'RoomsApi@update');
2020-10-31 21:37:29 +01:00
2020-05-24 19:35:19 +02:00
$router->get('/api/devices', 'DevicesApi@default');
2020-10-26 00:01:30 +01:00
$router->get('/api/plugins', 'PluginsApi@default');
2020-06-23 20:28:11 +02:00
$router->get('/api/users', 'UsersApi@default');
2020-07-27 20:00:41 +02:00
$router->get('/api/server', 'ServerApi@default');
2020-07-30 16:31:25 +02:00
$router->get('/api/server/log', 'ServerApi@logStatus');
2020-10-31 21:37:29 +01:00
2020-05-24 19:42:03 +02:00
$router->post('/api/widgets/{widgetId}/run', 'WidgetApi@run');
2020-08-25 15:12:25 +02:00
$router->get('/api/widgets/{widgetId}/detail', 'WidgetApi@detail');
2020-10-31 21:37:29 +01:00
$router->get('/api/widgets/{widgetId}/detail/{period}', 'WidgetApi@detail');
2020-05-26 21:47:36 +02:00
2020-07-21 10:29:26 +02:00
//cron
$router->post('/cron/clean', 'CronApi@clean');
2020-08-31 21:23:23 +02:00
$router->post('/cron/fetch', 'CronApi@fetch');
2020-05-26 21:42:39 +02:00
2020-06-28 16:45:05 +02:00
//Google Home - API
2020-05-17 01:27:06 +02:00
$router->any('/api/HA/auth', 'Oauth');
2020-05-16 17:18:27 +02:00
$router->any('/api/HA', 'GoogleHomeApi@response');
2020-06-28 16:45:05 +02:00
//Endpoints API
2020-07-14 18:24:21 +02:00
$router->post('/api/endpoint/', 'EndpointsApi@default');
2020-07-15 12:54:45 +02:00
$router->any('/api/update/', 'UpdatesApi@default');
2020-07-14 19:59:18 +02:00
$router->any('/api/users/status', 'UsersApi@status');
2021-01-04 17:08:56 +01:00
$router->any('/api/users/subscribe', 'UsersApi@subscribe');
2020-06-28 16:45:05 +02:00
2020-05-16 17:18:27 +02:00
// examples
$router->any('/api/example', 'ExampleApi@example');
$router->any('/example', 'ExampleController@index');
$router->any('/example/subpage', 'ExampleController@subpage');
2020-10-03 21:44:09 +02:00
//module routes
//$router->any('/plugins/spotify/callback', 'Spotify@callback');
2020-05-16 17:18:27 +02:00
$router->run($_SERVER['REQUEST_METHOD'], '/'.(isset($_GET['url']) ? $_GET['url'] : ''));