-
Notifications
You must be signed in to change notification settings - Fork 0
/
route.php
29 lines (21 loc) · 935 Bytes
/
route.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php
namespace App;
use App\domain\AuthToken;
use Bramus\Router\Router;
$router = new Router();
// Auth Middleware, if code becomes too big in here, use Chain of responsibility
$router->before('GET|POST|DELETE', '/pizza.*', function (){
$auth = (new AuthToken())->decode(isset($_SERVER['HTTP_AUTHORIZATION']) ? $_SERVER['HTTP_AUTHORIZATION'] : null);
if (!$auth){
exit();
}
});
// Pizza
$router->get('/pizza(/\w+)?', 'App\data\controllers\PizzaController@read');
$router->post('/pizza/create', 'App\data\controllers\PizzaController@create');
$router->post('/pizza/update/(\w+)', 'App\data\controllers\PizzaController@update');
$router->delete('/pizza/delete/(\w+)', 'App\data\controllers\PizzaController@delete');
// Pizza Types
$router->get('/type(/\w+)?', 'App\data\controllers\PizzaTypeController@read');
$router->post('/type/create', 'App\data\controllers\PizzaTypeController@create');
$router->run();