Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add filter parameters to User Guide #1908

Merged
merged 3 commits into from
Apr 2, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion user_guide_src/source/incoming/routing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ If you need to assign options to a group, like a `namespace <#assigning-namespac

This would handle a resource route to the ``App\API\v1\Users`` controller with the ``/api/users`` URI.

You can also use ensure that a specific `filter </incoming/filters.html>`_ gets ran for a group of routes. This will always
You can also use ensure that a specific `filter </incoming/filters.html>`_ runs for a group of routes. This will always
run the filter before or after the controller. This is especially handy during authentication or api logging::

$routes->group('api', ['filter' => 'api-auth'], function($routes)
Expand Down Expand Up @@ -393,6 +393,19 @@ can modify the generated routes, or further restrict them. The ``$options`` arra
$routes->map($array, $options);
$routes->group('name', $options, function());

Applying Filters
----------------

You can alter the behavior of specific routes by supplying a filter to run before or after the controller. This is especially handy during authentication or api logging::

$routes->add('admin',' AdminController::index', ['filter' => 'admin-auth']);

The value for the filter must match one of the aliases defined within ``app/Config/Filters.php``. You may also supply parameters to be passed to the filter's ``before()`` and ``after()`` methods::

$routes->add('users/delete/(:segment)', 'AdminController::index', ['filter' => 'admin-auth:dual,noreturn']);

See `Controller filters </incoming/filters.html>`_ for more information on setting up filters.

Assigning Namespace
-------------------

Expand Down