PHP_SMART_HOME_V3/app/Routes.php

32 lines
887 B
PHP
Raw Normal View History

2020-04-20 19:49:30 +00:00
<?php
$router = new Router();
$router->setDefault(function(){
2020-04-21 16:33:23 +00:00
echo $_GET['url'].': 404';
2020-04-20 19:49:30 +00:00
});
2020-04-21 12:11:34 +00:00
//Pages
2020-05-02 19:24:21 +00:00
$router->any('/', 'Log');
2020-04-21 12:11:34 +00:00
$router->any('/login', 'Login');
$router->any('/logout', 'Logout');
$router->any('/automation', 'Automation');
$router->any('/setting', 'Setting');
$router->any('/ajax', 'Ajax');
2020-04-29 14:10:33 +00:00
$router->post('/api/login', 'AuthApi@login');
2020-05-12 17:41:46 +00:00
$router->post('/api/logout', 'AuthApi@logout');
$router->post('/api/devices', 'DevicesApi@default');
$router->post('/api/rooms', 'RoomsApi@default');
2020-04-29 14:10:33 +00:00
2020-04-30 17:40:34 +00:00
$router->get('/api/HA/auth', 'GoogleHomeApi@autorize');
2020-05-02 11:18:15 +00:00
$router->any('/api/HA', 'GoogleHomeApi@response');
2020-04-29 14:10:33 +00:00
2020-04-29 18:14:53 +00:00
// examples
$router->any('/api/example', 'ExampleApi@example');
$router->any('/example', 'ExampleController@index');
$router->any('/example/subpage', 'ExampleController@subpage');
2020-04-24 19:54:25 +00:00
2020-04-21 17:37:56 +00:00
$router->run($_SERVER['REQUEST_METHOD'], '/'.(isset($_GET['url']) ? $_GET['url'] : ''));