Created Rest module

This commit is contained in:
Alejandro Celaya
2016-07-19 17:07:59 +02:00
parent 95d0beea3c
commit 55f954f50f
22 changed files with 127 additions and 86 deletions

View File

@@ -0,0 +1,16 @@
<?php
use Shlinkio\Shlink\Rest\Middleware;
return [
'middleware_pipeline' => [
'rest' => [
'path' => '/rest',
'middleware' => [
Middleware\CheckAuthenticationMiddleware::class,
Middleware\CrossDomainMiddleware::class,
],
'priority' => 5,
],
],
];

View File

@@ -0,0 +1,9 @@
<?php
return [
'rest' => [
'username' => getenv('REST_USER'),
'password' => getenv('REST_PASSWORD'),
],
];

View File

@@ -0,0 +1,39 @@
<?php
use Shlinkio\Shlink\Rest\Action;
return [
'routes' => [
[
'name' => 'rest-authenticate',
'path' => '/rest/authenticate',
'middleware' => Action\AuthenticateMiddleware::class,
'allowed_methods' => ['POST', 'OPTIONS'],
],
[
'name' => 'rest-create-shortcode',
'path' => '/rest/short-codes',
'middleware' => Action\CreateShortcodeMiddleware::class,
'allowed_methods' => ['POST', 'OPTIONS'],
],
[
'name' => 'rest-resolve-url',
'path' => '/rest/short-codes/{shortCode}',
'middleware' => Action\ResolveUrlMiddleware::class,
'allowed_methods' => ['GET', 'OPTIONS'],
],
[
'name' => 'rest-lActionist-shortened-url',
'path' => '/rest/short-codes',
'middleware' => Action\ListShortcodesMiddleware::class,
'allowed_methods' => ['GET'],
],
[
'name' => 'rest-get-visits',
'path' => '/rest/visits/{shortCode}',
'middleware' => Action\GetVisitsMiddleware::class,
'allowed_methods' => ['GET', 'OPTIONS'],
],
],
];

View File

@@ -0,0 +1,22 @@
<?php
use Acelaya\ZsmAnnotatedServices\Factory\V3\AnnotatedFactory;
use Shlinkio\Shlink\Rest\Action;
use Shlinkio\Shlink\Rest\Middleware;
use Zend\ServiceManager\Factory\InvokableFactory;
return [
'services' => [
'factories' => [
Action\AuthenticateMiddleware::class => AnnotatedFactory::class,
Action\CreateShortcodeMiddleware::class => AnnotatedFactory::class,
Action\ResolveUrlMiddleware::class => AnnotatedFactory::class,
Action\GetVisitsMiddleware::class => AnnotatedFactory::class,
Action\ListShortcodesMiddleware::class => AnnotatedFactory::class,
Middleware\CrossDomainMiddleware::class => InvokableFactory::class,
Middleware\CheckAuthenticationMiddleware::class => AnnotatedFactory::class,
],
],
];