在 Bolt 扩展中,我有很多路由绑定到应用程序的实例,如下所示:
$this->app->post(Extension::API_PREFIX . "session", array($this, 'login'))
->bind('login');
$this->app->delete(Extension::API_PREFIX . "session", array($this, 'logout'))
->bind('logout');
$this->app->post(Extension::API_PREFIX . "resetpassword", array($this, 'reset_password'))
->bind('reset_password');
$this->app->post(Extension::API_PREFIX . "forgotpassword", array($this, 'forgot_password'))
->bind('forgot_password');
$this->app->post(Extension::API_PREFIX . "changepassword", array($this, 'change_password'))
->bind('change_password');
$this->app->get(Extension::API_PREFIX . "session", array($this, 'get_session'))
->bind('get_session');
但我想对before
路由的子集运行过滤器。如何将其中一些路由组合在一起并绑定过滤器?到目前为止,我只发现了如何在所有路由上使用过滤器,如下所示:
$this->app->before(function (Request $request) {
// Filter request here
});