|
3 | 3 | namespace Pdsinterop\Solid\Service; |
4 | 4 |
|
5 | 5 | use League\Container\Container; |
| 6 | +use League\Route\RouteGroup; |
6 | 7 | use League\Route\Router; |
7 | 8 | use League\Route\Strategy\ApplicationStrategy; |
8 | 9 | use Pdsinterop\Solid\Controller\AddSlashToPathController; |
@@ -47,18 +48,20 @@ final public function populate() : Router |
47 | 48 |
|
48 | 49 | /*/ Map routes and groups /*/ |
49 | 50 | $router->map('GET', '/', HelloWorldController::class)->setScheme($scheme); |
50 | | - $this->mapProfile($router, $scheme); |
| 51 | + $router->group('/profile', $this->createProfileGroup())->setScheme($scheme); |
51 | 52 |
|
52 | 53 | return $router; |
53 | 54 | } |
54 | 55 |
|
55 | 56 | ////////////////////////////// UTILITY METHODS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\ |
56 | 57 |
|
57 | | - private function mapProfile(Router $router, string $scheme) : void |
| 58 | + private function createProfileGroup() : Callable |
58 | 59 | { |
59 | | - $router->map('GET', '/profile', AddSlashToPathController::class)->setScheme($scheme); |
60 | | - $router->map('GET', '/profile/', ProfileController::class)->setScheme($scheme); |
61 | | - $router->map('GET', '/profile/card', CardController::class)->setScheme($scheme); |
62 | | - $router->map('GET', '/profile/card{extension}', CardController::class)->setScheme($scheme); |
| 60 | + return static function (RouteGroup $group) { |
| 61 | + $group->map('GET', '/', AddSlashToPathController::class); |
| 62 | + $group->map('GET', '', ProfileController::class); |
| 63 | + $group->map('GET', '/card', CardController::class); |
| 64 | + $group->map('GET', '/card{extension}', CardController::class); |
| 65 | + }; |
63 | 66 | } |
64 | 67 | } |
0 commit comments