2017 © Pedro Peláez
 

library server-middleware-dispatcher

Cormy PSR-7 server middleware dispatcher

image

cormy/server-middleware-dispatcher

Cormy PSR-7 server middleware dispatcher

  • Wednesday, November 23, 2016
  • by schnittstabil
  • Repository
  • 1 Watchers
  • 0 Stars
  • 40 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Cormy Server Middleware Dispatcher Build Status Coverage Status Scrutinizer Code Quality

SensioLabsInsight, (*1)

:nut_and_bolt: Cormy PSR-7 server middleware dispatcher, (*2)

Install

composer require cormy/server-middleware-dispatcher

Usage

use Cormy\Server\MiddlewareDispatcher;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;

$middleware = function (ServerRequestInterface $request):\Generator {
    // delegate $request to the next request handler, i.e. the $finalHandler below
    $response = (yield $request);

    return $response->withHeader('X-PoweredBy', 'Unicorns');
};

$finalHandler = function (ServerRequestInterface $request):ResponseInterface {
    return new \Zend\Diactoros\Response();
};

// create a dispatcher
$dispatcher = new MiddlewareDispatcher($middleware, $finalHandler);

// dispatch a request
$response = $dispatcher(new \Zend\Diactoros\ServerRequest());

API

Cormy\Server\MiddlewareDispatcher implements Cormy\Server\RequestHandlerInterface

MiddlewareDispatcher::__construct

/**
 * Create a Cormy PSR-7 server middleware dispatcher.
 *
 * @param callable|MiddlewareInterface     $middleware
 * @param callable|RequestHandlerInterface $finalHandler
 */
public function __construct(callable $middleware, callable $finalHandler)

Inherited from Cormy\Server\RequestHandlerInterface::__invoke

/**
 * Process an incoming server request and return the response.
 *
 * @param ServerRequestInterface $request
 *
 * @return ResponseInterface
 */
public function __invoke(ServerRequestInterface $request):ResponseInterface;

License

MIT © Michael Mayer, (*3)

The Versions

23/11 2016

dev-master

9999999-dev

Cormy PSR-7 server middleware dispatcher

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware psr psr-7 server http dispatcher request response http-message cormy

23/11 2016

0.1.0

0.1.0.0

Cormy PSR-7 server middleware dispatcher

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware psr psr-7 server http dispatcher request response http-message cormy