Add filters to routing. - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Feature Requests (https://forum.codeigniter.com/forumdisplay.php?fid=29) +--- Thread: Add filters to routing. (/showthread.php?tid=72072) |
Add filters to routing. - HTLove - 11-01-2018 Currently, Filters only support for a group of routes. How to add filters to one URI. https://bcit-ci.github.io/CodeIgniter4/incoming/routing.html Thanks RE: Add filters to routing. - puschie - 11-05-2018 do you mean something like this : $routes->add('feed', function() { $rss = new RSSFeeder(); return $rss->feed('general'); }); RE: Add filters to routing. - HTLove - 11-06-2018 No. It not work to: $routes->add('users/profile', 'Users::profile', ['as' => 'profile', 'filter' => '123]); RE: Add filters to routing. - ciadmin - 03-06-2019 Can you not do something like... public filters = [ 'users/profile' => ['before' => ['Filter123']], // ... ]; See https://codeigniter4.github.io/CodeIgniter4/incoming/filters.html#filters RE: Add filters to routing. - br_salviano - 09-23-2019 How can I apply a filter to specific route? I'm trying something like this: $routes->get('api/category', 'CategoryApi::read'); $routes->post('api/category', 'CategoryApi::create', ['filter' => 'auth']); But the filter is being applied in both routes. RE: Add filters to routing. - kilishan - 09-23-2019 You're right that it only works for groups at the moment. If you want to specify it for a single, you would currently need to do it in the Filters config file. Adding to a single route is a good idea, and one that could be added after 4.0 final release. Would you mind making an issue over at Github about this so it gets put on the road map. |