2017 © Pedro Peláez
 

library middleware

Request middleware

image

api-clients/middleware

Request middleware

  • Saturday, July 14, 2018
  • by WyriHaximus
  • Repository
  • 2 Watchers
  • 1 Stars
  • 22,821 Installations
  • PHP
  • 23 Dependents
  • 0 Suggesters
  • 3 Forks
  • 3 Open issues
  • 14 Versions
  • 15 % Grown

The README.md

API Client middleware for PHP 7.x

Build Status Latest Stable Version Total Downloads Code Coverage License PHP 7 ready, (*1)

This library contains the a async MiddlewareRunner used in our api clients. It provides an interface for all middlewares. Middlewares are ordered by priority when they where added to the MiddlewareRunner. Order of middlewares with the same priority is not guaranteed., (*2)

A number of traits are provided for your convenience, if your middleware implementation does not require all the methods defined in the MiddlewareInterface., (*3)

Locator

The locator can be used by your application to fetch middleware instances. It will check whether the created instance implements the MiddlewareInterface. Currently the only provided locator is the ContainerLocator which accepts a Psr\Container\ContainerInterface to fetch your middleware instances., (*4)

Example

    $container = /* ... */;
    $locator = new ContainerLocator($container);
    $middlewares = [];

    $config = [
        'middlewares' => [/*...*/]
        'options' => [/*...*/]
    ];

    foreach ($config['middlewares'] as $middleware) {
       $middlewares[] = $locator->get($middleware);
    }

    $runner = new MiddlewareRunner($config['options'], $middelwares);

    $runner->pre($request)->then(function ($request) use ($options) {
        return resolve($this->browser->send(
            $request
        ));
    }, function (ResponseInterface $response) {
        return resolve($response);
    })->then(function (ResponseInterface $response) use ($runner) {
        return $runner->post($response);
    })->otherwise(function (Throwable $throwable) use ($runner) {
        return reject($runner->error($throwable));
    });

License

The MIT License (MIT), (*5)

Copyright (c) 2017 Cees-Jan Kiewiet, (*6)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:, (*7)

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software., (*8)

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE., (*9)

The Versions

10/07 2018

dev-dependabot/composer/api-clients/test-utilities-4.3.0

dev-dependabot/composer/api-clients/test-utilities-4.3.0

Request middleware

  Sources   Download

MIT

The Requires

 

The Development Requires

10/07 2018

dev-dependabot/composer/react/promise-2.7.0

dev-dependabot/composer/react/promise-2.7.0

Request middleware

  Sources   Download

MIT

The Requires

 

The Development Requires

17/06 2017

dev-use-annotations-for-method-level-priority

dev-use-annotations-for-method-level-priority

Request middleware

  Sources   Download

MIT

The Requires

 

The Development Requires

14/06 2017

dev-feature-stateful-middlewares

dev-feature-stateful-middlewares

Request middleware

  Sources   Download

MIT

The Requires

 

The Development Requires

05/12 2016

1.0.0

1.0.0.0

Request middleware

  Sources   Download

MIT

The Requires

 

The Development Requires