mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-06 23:33:13 +08:00
Moved most of rest routes config to their actions
This commit is contained in:
@@ -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,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user