2017 © Pedro Peláez
 

library handlers

Psr-15 request handler decorators

image

ellipse/handlers

Psr-15 request handler decorators

  • Monday, March 19, 2018
  • by pmall
  • Repository
  • 1 Watchers
  • 1 Stars
  • 533 Installations
  • PHP
  • 4 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 3 % Grown

The README.md

Request handler decorators

This package provides Psr-15 request handler decorators., (*1)

Require php >= 7.0, (*2)

Installation composer require ellipse/handlers, (*3)

Run tests ./vendor/bin/kahlan, (*4)

Fallback request handler

An usual starting point for request handler decorators is to have a request handler returning a default response when its ->handle() method is called. This package provides an Ellipse\Handlers\FallbackRequestHandler class implementing this logic., (*5)

<?php

namespace App;

use Ellipse\Handlers\FallbackRequestHandler;

// Get some fallback Psr-7 response, here with a 404 status code.
$response = some_psr7_response_factory()->withStatus(404);

// Create a fallback request handler returning the response.
$fallback = new FallbackRequestHandler($response);

// The response is returned.
$response = $fallback->handle($request);

Request handler with middleware

This package provides an Ellipse\Handlers\RequestHandlerWithMiddleware class allowing to wrap a middleware around a request handler., (*6)

<?php

namespace App;

use Ellipse\Handlers\FallbackRequestHandler;
use Ellipse\Handlers\RequestHandlerWithMiddleware;

// create Psr-15 middleware and request handler.
$middleware = new SomeMiddleware;
$handler = new FallbackRequestHandler($response);

// Wrap the middleware around the request handler.
$decorated = new RequestHandlerWithMiddleware($handler, $middleware);

// The request goes through the middleware then hit the fallback request handler.
$response = $decorated->handle($request);

Request handler with middleware stack

This package provides an Ellipse\Handlers\RequestHandlerWithMiddlewareStack class allowing to wrap many middleware around a request handler in LIFO order., (*7)

<?php

namespace App;

use Ellipse\Handlers\FallbackRequestHandler;
use Ellipse\Handlers\RequestHandlerWithMiddlewareStack;

// create Psr-15 middleware and request handler.
$middleware1 = new SomeMiddleware1;
$middleware2 = new SomeMiddleware2;
$handler = new FallbackRequestHandler($response);

// Wrap the middleware around the request handler in LIFO order.
$decorated = new RequestHandlerWithMiddlewareStack($handler, [
    $middleware2,
    $middleware1,
]);

// The request goes through middleware1, middleware2, then hit the fallback request handler.
$response = $decorated->handle($request);

Request handler with middleware queue

This package provides an Ellipse\Handlers\RequestHandlerWithMiddlewareQueue class allowing to wrap many middleware around a request handler in FIFO order., (*8)

<?php

namespace App;

use Ellipse\Handlers\FallbackRequestHandler;
use Ellipse\Handlers\RequestHandlerWithMiddlewareQueue;

// create Psr-15 middleware and request handler.
$middleware1 = new SomeMiddleware1;
$middleware2 = new SomeMiddleware2;
$handler = new FallbackRequestHandler($response);

// Wrap the middleware around the request handler in FIFO order.
$decorated = new RequestHandlerWithMiddlewareQueue($handler, [
    $middleware1,
    $middleware2,
]);

// The request goes through middleware1, middleware2, then hit the fallback request handler.
$response = $decorated->handle($request);

The Versions

19/03 2018

dev-master

9999999-dev https://github.com/ellipsephp/handlers

Psr-15 request handler decorators

  Sources   Download

MIT

The Requires

 

The Development Requires

by Pierre Mallinjoud

middleware psr-7 request resolver psr-15 request-handler

19/03 2018

1.1.1

1.1.1.0 https://github.com/ellipsephp/handlers

Psr-15 request handler decorators

  Sources   Download

MIT

The Requires

 

The Development Requires

by Pierre Mallinjoud

middleware psr-15 request-handler

12/03 2018

1.1.0

1.1.0.0 https://github.com/ellipsephp/handlers

Psr-15 request handler decorators

  Sources   Download

MIT

The Requires

 

The Development Requires

by Pierre Mallinjoud

middleware psr-15 request-handler

23/02 2018

1.0.1

1.0.1.0 https://github.com/ellipsephp/handlers

Psr-15 request handler decorators

  Sources   Download

MIT

The Requires

 

The Development Requires

by Pierre Mallinjoud

middleware psr-15 request-handler

22/02 2018

1.0.0

1.0.0.0 https://github.com/ellipsephp/handlers

Psr-15 request handler decorators

  Sources   Download

MIT

The Requires

 

The Development Requires

by Pierre Mallinjoud

middleware psr-15 request-handler