Skip to content
Permalink
Browse files

Add Slack Jira Pipeline

Add /slack_jira POST route
Validate Body
  • Loading branch information...
stringerbell committed May 29, 2016
1 parent 6b21dd5 commit cd6bda555a4546306bbc7754f0d3a8229799b811
@@ -1,4 +1,6 @@
<?php
use App\Pipeline\SlackJiraPipeline;
use App\Validator\ValidateBody;
use Zend\Expressive\Application;
use Zend\Expressive\Container\ApplicationFactory;
use Zend\Expressive\Helper;
@@ -14,11 +16,13 @@
'invokables' => [
// Fully\Qualified\InterfaceName::class => Fully\Qualified\ClassName::class,
Helper\ServerUrlHelper::class => Helper\ServerUrlHelper::class,
ValidateBody::class => ValidateBody::class,
],
// Use 'factories' for services provided by callbacks/factory classes.
'factories' => [
Application::class => ApplicationFactory::class,
Helper\UrlHelper::class => Helper\UrlHelperFactory::class,
'factories' => [
Application::class => ApplicationFactory::class,
Helper\UrlHelper::class => Helper\UrlHelperFactory::class,
SlackJiraPipeline::class => SlackJiraPipeline::class,
],
],
];
@@ -48,6 +48,7 @@
'middleware' => [
ApplicationFactory::ROUTING_MIDDLEWARE,
Helper\UrlHelperMiddleware::class,
Helper\BodyParams\BodyParamsMiddleware::class,
// Add more middleware here that needs to introspect the routing
// results; this might include:
// - route-based authentication
@@ -1,5 +1,7 @@
<?php
use App\Pipeline\SlackJiraPipeline;
return [
'dependencies' => [
'invokables' => [
@@ -24,5 +26,11 @@
'middleware' => App\Action\PingAction::class,
'allowed_methods' => ['GET'],
],
[
'name' => '/slack_jira',
'path' => '/slack_jira',
'middleware' => [SlackJiraPipeline::class],
'allowed_methods' => ['POST'],
],
],
];
@@ -0,0 +1,18 @@
<?php
namespace App\Pipeline;
use App\Validator\ValidateBody;
use Interop\Container\ContainerInterface;
use Zend\Stratigility\MiddlewarePipe;
class SlackJiraPipeline
{
public function __invoke(ContainerInterface $container)
{
$pipeline = new MiddlewarePipe();
$pipeline->pipe($container->get(ValidateBody::class));
return $pipeline;
}
}
@@ -0,0 +1,19 @@
<?php
namespace App\Validator;
use Psr\Http\Message\ServerRequestInterface;
use Zend\Expressive\Container\Exception\InvalidArgumentException;
use Zend\Stratigility\Http\ResponseInterface;
class ValidateBody
{
public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next)
{
$body = $request->getParsedBody();
if (!$body) {
throw new InvalidArgumentException("Invalid Body");
}
return $next($request, $response);
}
}

0 comments on commit cd6bda5

Please sign in to comment.
You can’t perform that action at this time.