|
18 | 18 | use League\Route\Strategy\ApplicationStrategy; |
19 | 19 |
|
20 | 20 | use Pdsinterop\Solid\Controller\AddSlashToPathController; |
21 | | -use Pdsinterop\Solid\Controller\AuthorizeController; |
22 | 21 | use Pdsinterop\Solid\Controller\ApprovalController; |
| 22 | +use Pdsinterop\Solid\Controller\AuthorizeController; |
23 | 23 | use Pdsinterop\Solid\Controller\CorsController; |
24 | 24 | use Pdsinterop\Solid\Controller\HandleApprovalController; |
25 | 25 | use Pdsinterop\Solid\Controller\HelloWorldController; |
|
31 | 31 | use Pdsinterop\Solid\Controller\Profile\CardController; |
32 | 32 | use Pdsinterop\Solid\Controller\Profile\ProfileController; |
33 | 33 | use Pdsinterop\Solid\Controller\RegisterController; |
| 34 | +use Pdsinterop\Solid\Controller\ResourceController; |
34 | 35 | use Pdsinterop\Solid\Controller\TokenController; |
| 36 | +use Pdsinterop\Solid\Resources\Server as ResourceServer; |
35 | 37 |
|
36 | 38 | use Psr\Http\Message\ResponseInterface; |
37 | 39 | use Psr\Http\Message\ServerRequestInterface; |
|
80 | 82 | return $template; |
81 | 83 | }); |
82 | 84 |
|
| 85 | +$container->add(ResourceController::class, function () use ($container) { |
| 86 | + $filesystem = $container-> get(FilesystemInterface::class); |
| 87 | + |
| 88 | + require_once __DIR__ . '/../lib/solid-crud/src/Server.php'; |
| 89 | + |
| 90 | + $server = new ResourceServer($filesystem, new Response()); |
| 91 | + |
| 92 | + return new ResourceController($server); |
| 93 | +}); |
| 94 | + |
83 | 95 | $controllers = [ |
84 | 96 | AddSlashToPathController::class, |
85 | 97 | ApprovalController::class, |
|
149 | 161 | $router->map('POST', '/token', TokenController::class)->setScheme($scheme); |
150 | 162 | $router->map('POST', '/token/', TokenController::class)->setScheme($scheme); |
151 | 163 |
|
| 164 | +$router->group('/data', static function (\League\Route\RouteGroup $group) { |
| 165 | + $methods = [ |
| 166 | + 'DELETE', |
| 167 | + 'GET', |
| 168 | + 'HEAD', |
| 169 | + // 'OPTIONS', // @TODO: This breaks because of the CorsController being added to `OPTION /*` in the index.php |
| 170 | + 'PATCH', |
| 171 | + 'POST', |
| 172 | + 'PUT', |
| 173 | + ]; |
| 174 | + |
| 175 | + array_walk($methods, static function ($method) use (&$group) { |
| 176 | + $group->map($method, '/', AddSlashToPathController::class); |
| 177 | + $group->map($method, '{path:.*}', ResourceController::class); |
| 178 | + }); |
| 179 | +})->setScheme($scheme); |
| 180 | + |
152 | 181 | try { |
153 | 182 | $response = $router->dispatch($request); |
154 | 183 | } catch (HttpException $exception) { |
|
0 commit comments