Moved most of rest routes config to their actions

This commit is contained in:
Alejandro Celaya
2018-05-01 18:28:37 +02:00
parent c9ce56eea5
commit ef3c4aadf2
12 changed files with 42 additions and 62 deletions

View File

@@ -12,7 +12,7 @@ use Psr\Log\NullLogger;
abstract class AbstractRestAction implements RequestHandlerInterface, RequestMethodInterface, StatusCodeInterface
{
protected const ROUTE_PATH = '';
protected const ALLOWED_METHODS = [];
protected const ROUTE_ALLOWED_METHODS = [];
/**
* @var LoggerInterface
@@ -30,7 +30,7 @@ abstract class AbstractRestAction implements RequestHandlerInterface, RequestMet
'name' => static::class,
'middleware' => \array_merge($prevMiddleware, [static::class], $postMiddleware),
'path' => static::ROUTE_PATH,
'allowed_methods' => static::ALLOWED_METHODS,
'allowed_methods' => static::ROUTE_ALLOWED_METHODS,
];
}
}

View File

@@ -15,6 +15,9 @@ use Zend\I18n\Translator\TranslatorInterface;
class AuthenticateAction extends AbstractRestAction
{
protected const ROUTE_PATH = '/authenticate';
protected const ROUTE_ALLOWED_METHODS = [self::METHOD_POST];
/**
* @var TranslatorInterface
*/

View File

@@ -16,6 +16,9 @@ use Zend\I18n\Translator\TranslatorInterface;
class EditShortCodeAction extends AbstractRestAction
{
protected const ROUTE_PATH = '/short-codes/{shortCode}';
protected const ROUTE_ALLOWED_METHODS = [self::METHOD_PUT];
/**
* @var ShortUrlServiceInterface
*/

View File

@@ -14,6 +14,9 @@ use Zend\I18n\Translator\TranslatorInterface;
class EditShortcodeTagsAction extends AbstractRestAction
{
protected const ROUTE_PATH = '/short-codes/{shortCode}/tags';
protected const ROUTE_ALLOWED_METHODS = [self::METHOD_PUT];
/**
* @var ShortUrlServiceInterface
*/

View File

@@ -15,6 +15,9 @@ use Zend\I18n\Translator\TranslatorInterface;
class GetVisitsAction extends AbstractRestAction
{
protected const ROUTE_PATH = '/short-codes/{shortCode}/visits';
protected const ROUTE_ALLOWED_METHODS = [self::METHOD_GET];
/**
* @var VisitsTrackerInterface
*/

View File

@@ -16,6 +16,9 @@ class ListShortcodesAction extends AbstractRestAction
{
use PaginatorUtilsTrait;
protected const ROUTE_PATH = '/short-codes';
protected const ROUTE_ALLOWED_METHODS = [self::METHOD_GET];
/**
* @var ShortUrlServiceInterface
*/

View File

@@ -15,6 +15,9 @@ use Zend\I18n\Translator\TranslatorInterface;
class ResolveUrlAction extends AbstractRestAction
{
protected const ROUTE_PATH = '/short-codes/{shortCode}';
protected const ROUTE_ALLOWED_METHODS = [self::METHOD_GET];
/**
* @var UrlShortenerInterface
*/

View File

@@ -12,6 +12,9 @@ use Zend\Diactoros\Response\JsonResponse;
class CreateTagsAction extends AbstractRestAction
{
protected const ROUTE_PATH = '/tags';
protected const ROUTE_ALLOWED_METHODS = [self::METHOD_POST];
/**
* @var TagServiceInterface
*/

View File

@@ -12,6 +12,9 @@ use Zend\Diactoros\Response\EmptyResponse;
class DeleteTagsAction extends AbstractRestAction
{
protected const ROUTE_PATH = '/tags';
protected const ROUTE_ALLOWED_METHODS = [self::METHOD_DELETE];
/**
* @var TagServiceInterface
*/

View File

@@ -12,6 +12,9 @@ use Zend\Diactoros\Response\JsonResponse;
class ListTagsAction extends AbstractRestAction
{
protected const ROUTE_PATH = '/tags';
protected const ROUTE_ALLOWED_METHODS = [self::METHOD_GET];
/**
* @var TagServiceInterface
*/

View File

@@ -16,6 +16,9 @@ use Zend\I18n\Translator\TranslatorInterface;
class UpdateTagAction extends AbstractRestAction
{
protected const ROUTE_PATH = '/tags';
protected const ROUTE_ALLOWED_METHODS = [self::METHOD_PUT];
/**
* @var TagServiceInterface
*/