取下中間件特定的路由我加中間件到我的項目在SLIM
//Initiate a Slim instance
$app = new \Slim\Slim();
//Add Middleware for authentication
$app->add(new ExampleMiddleware();
但是,我要離開一些路線了中間件。 這裏是我的課:
class ExampleMiddleware extends Slim\Middleware {
public function __construct() {
//Define the urls that you want to exclude from Authentication
$this->whiteList =['/'];//This does not work
}
public function call(){
$res = User::authenticate($token); //Verify user
if ($res){
$this->next->call();//Continue to execute the request
} else {
$this->app->response->body(json_encode(['error' => 'denied']));
}
}
}
//Sample Route which returns a user from DB using Laravel
$app->get('/', function() use ($app) {
$u = User::find(22078);
$app->response->body($u->toJson());
});
我怎麼能離開例如「/」路線的認證處理的?
謝謝