37 lines
712 B
PHP
37 lines
712 B
PHP
<?php
|
|
|
|
// Application middleware
|
|
|
|
// e.g: $app->add(new \AllCapsMiddleware());
|
|
|
|
/*global $app;
|
|
|
|
class ExampleMiddleware
|
|
{
|
|
public function __invoke($request, $response, $next)
|
|
{
|
|
$response->getBody()->write('BEFORE');
|
|
$response = $next($request, $response);
|
|
$response->getBody()->write('AFTER');
|
|
|
|
return $response;
|
|
}
|
|
}
|
|
|
|
$app->add( new ExampleMiddleware() );*/
|
|
|
|
|
|
/*
|
|
global $app;
|
|
global $_GET;
|
|
$app->hook('slim.before.dispatch', function() use ($app, $_GET) {
|
|
$publicRoutes = array('login', 'welcome');
|
|
if(!in_array($app->router()->getCurrentRoute(), $publicRoutes)
|
|
// Get the token
|
|
$result = API::validate($token);
|
|
if(!$result) {
|
|
$app->redirect('/login');
|
|
}
|
|
$_GET = ['1222' => 'sdfsdf'];
|
|
});*/
|