Respect/Rest — Issue #12: Hierarchical Routing
Author: alganet
Created: 2011-10-13 23:46:27+00:00
State: open

Routes inside routes respect their parents patterns by concatenating them. Parents acts as hubs:

```php
any('/users/*', function($username=null) {
return showMyUserPlease($username);
})->children(
$router->any('/lists', function($username=null) {
return showMyUserLists($username);
})
);

```

Sample above would match `/users/alganet` and `/users/alganet/lists` and route each url to its proper children.

Children could be reused:

```php
any('/lists', function($username=null) {
return showMyUserLists($username);
}

$router->any('/users/*', function($username=null) {
return showMyUserPlease($username);
})->children($listsRoute);

$router->any('/admins/*', function($username=null) {
return showMyUserPlease($username);
})->children($listsRoute);

```

A new empty route type could be created to be just a namespace for other routes:

```php
any('/users/*')->children(
$router->any('/lists', function($username=null) {
return showMyUserLists($username);
}),
$router->any('/followers', function($username=null) {
return showFollowers($username);
})
);

```

Sample above will match `/users/alganet/lists` and `/users/alganet/followers`, but will not match just `/users/alganet`.