2017-07-21 19:59:16 +02:00
|
|
|
<?php
|
2020-04-23 18:26:12 +02:00
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
use Psr\Container\ContainerInterface;
|
|
|
|
|
use Zend\Expressive\Application;
|
|
|
|
|
use Zend\Expressive\MiddlewareFactory;
|
|
|
|
|
|
2017-07-21 19:59:16 +02:00
|
|
|
/**
|
|
|
|
|
* Setup routes with a single request method:
|
|
|
|
|
*
|
2020-04-23 18:26:12 +02:00
|
|
|
* $app->get('/', App\Handler\HomePageHandler::class, 'home');
|
|
|
|
|
* $app->post('/album', App\Handler\AlbumCreateHandler::class, 'album.create');
|
|
|
|
|
* $app->put('/album/:id', App\Handler\AlbumUpdateHandler::class, 'album.put');
|
|
|
|
|
* $app->patch('/album/:id', App\Handler\AlbumUpdateHandler::class, 'album.patch');
|
|
|
|
|
* $app->delete('/album/:id', App\Handler\AlbumDeleteHandler::class, 'album.delete');
|
2017-07-21 19:59:16 +02:00
|
|
|
*
|
|
|
|
|
* Or with multiple request methods:
|
|
|
|
|
*
|
2020-04-23 18:26:12 +02:00
|
|
|
* $app->route('/contact', App\Handler\ContactHandler::class, ['GET', 'POST', ...], 'contact');
|
2017-07-21 19:59:16 +02:00
|
|
|
*
|
|
|
|
|
* Or handling all request methods:
|
|
|
|
|
*
|
2020-04-23 18:26:12 +02:00
|
|
|
* $app->route('/contact', App\Handler\ContactHandler::class)->setName('contact');
|
2017-07-21 19:59:16 +02:00
|
|
|
*
|
|
|
|
|
* or:
|
|
|
|
|
*
|
|
|
|
|
* $app->route(
|
|
|
|
|
* '/contact',
|
2020-04-23 18:26:12 +02:00
|
|
|
* App\Handler\ContactHandler::class,
|
2017-07-21 19:59:16 +02:00
|
|
|
* Zend\Expressive\Router\Route::HTTP_METHOD_ANY,
|
|
|
|
|
* 'contact'
|
|
|
|
|
* );
|
|
|
|
|
*/
|
2020-04-23 18:26:12 +02:00
|
|
|
return function (Application $app, MiddlewareFactory $factory, ContainerInterface $container) : void {
|
|
|
|
|
$app->get('/', App\Handler\HomePage::class, 'home');
|
|
|
|
|
$app->get('/api/galleries', App\Handler\ListGalleries::class, 'api.galleries');
|
|
|
|
|
$app->get('/image/{slug}/{image}[/{thumb}]', App\Handler\GetImage::class, 'download.image');
|
|
|
|
|
$app->get('/export-album/{slug}.zip', App\Handler\ExportAlbum::class, 'export.album');
|
2017-07-21 19:59:16 +02:00
|
|
|
|
2020-04-23 18:26:12 +02:00
|
|
|
$app->get('/api/album[/{id:\d+}]', App\Handler\Album::class, 'api.album');
|
|
|
|
|
$app->get('/api/image[/{id:\d+}]', App\Handler\Image::class, 'api.image');
|
|
|
|
|
$app->get('/api/collection[/{id:\d+}]', App\Handler\Collection::class, 'api.gallery');
|
|
|
|
|
};
|