diff --git a/docs/en/02_Developer_Guides/02_Controllers/02_Routing.md b/docs/en/02_Developer_Guides/02_Controllers/02_Routing.md index e1a05fed5..cbc0b766a 100644 --- a/docs/en/02_Developer_Guides/02_Controllers/02_Routing.md +++ b/docs/en/02_Developer_Guides/02_Controllers/02_Routing.md @@ -214,6 +214,30 @@ Director: 'feed': 'FeedController' ``` +## Root URL Handlers + +In some cases, the Director rule covers the entire URL you intend to match, and you simply want the controller to respond to a 'root' request. This request will automatically direct to an `index()` method if it exists on the controller, but you can also set a custom method to use in `$url_handlers` with the `'/'` key: + +```php +use SilverStripe\Control\Controller; + +class BreadAPIController extends Controller +{ + private static $allowed_actions = [ + 'getBreads', + 'createBread', + ]; + + private static $url_handlers = [ + 'GET /' => 'getBreads', + 'POST /' => 'createBread', + ]; +``` + +