Skip to content
This repository has been archived by the owner on Jun 30, 2020. It is now read-only.

Releases: oscarotero/psr7-middlewares

3.1.0

25 Sep 10:03
Compare
Choose a tag to compare
  • New middleware Payload
  • New middleware Uuid

3.0.1

12 Sep 16:08
Compare
Choose a tag to compare

SaveResponse: Fixed namespace resolution

3.0.0

12 Sep 15:47
Compare
Choose a tag to compare

Changed the way to get request attributes

Now, each middleware has static functions to get the values stored in the request. This avoid conflicts with other attributes. For example, using the AuraSession middleware:

//before
$session = $request->getAttribute('SESSION');

//from now
$session = Psr7Middlewares\Middleware\AuraSession::getSession($request);

The only exception is the parameters get from url by the routes (AuraRouter or FastRoute).

Use of PSR-6 in the Cache middleware

The Cache middleware use psr-6 implementations instead a directory:

//before
$middleware = Middleware::cache()->storage('path/to/dir');

//from now
$middleware = Middleware::cache(new PSR6CacheImplementation());

2.2.0

17 Aug 11:49
Compare
Choose a tag to compare
  • Merged ExceptionHandler and ErrorResponseHandler to a new middleware called ErrorHandler that allows register an external handlers to manage not only exceptions but also errors and shudown errors.
  • All external libraries uses by the middlewares are suggested in composer.json, instead required.

2.1.1

13 Aug 16:26
Compare
Choose a tag to compare

Fixed clientIp middleware to get the most trusted ip from "REMOTE_ADDR" server parameter.

2.1.0

12 Aug 12:15
Compare
Choose a tag to compare
  • Moved some code duplications to traits
  • Improved API, unified method names, etc
  • TrailingSlash can be configured to add the slash instead remove it

2.0.2

10 Aug 20:47
Compare
Choose a tag to compare

SaveResponse: only save responses with status code 200.

2.0.1

10 Aug 20:37
Compare
Choose a tag to compare
  • trailingSlash: The path "/" no more will be converted to "".
  • trailingSlash: Added basePath option

2.0.0

09 Aug 10:31
Compare
Choose a tag to compare

Improved the API a little bit:

  • Instead provide a streamFactory for each middleware that requires it, now you have to define using Middleware::setStreamFactory():

    //before
    $middlewares = [
      Middleware::exceptionHandler(function () {
          return new Stream();
      }),
      Middleware::minify(function () {
          return new Stream();
      })
    ];
    
    //Now:
    Middleware::setStreamFactory(function ($input, $mode) {
      return new Stream($input, $mode);
    });
    
    $middlewares = [
      Middleware::exceptionHandler(),
      Middleware::minify()
    ];
  • The options of the middlewares are provided using methods instead arguments in the constructor:

    //before:
    $middlewares = [
      Middleware::basicAuthentication($users, 'My-Realm'),
      Middleware::errorResponseHandler($handler, $extraArguments),
      Middleware::firewall($trusted, $untrusted),
      Middleware::minify($streamFactory, ['forCache' => true, 'inlineJs' => false])
    ];
    
    //now:
    $middlewares = [
      Middleware::basicAuthentication($users)
          ->realm('My-Realm'),
      Middleware::errorResponseHandler($handler)
          ->arguments($extraArguments),
      Middleware::firewall()
          ->trusted($trusted)
          ->untrusted($untrusted)
      Middleware::minify()
          ->forCache()
          ->inlineJs(false)
    ];

    This allows add more options in the future without change the api.

  • New Cache middleware to provide a simple gateway cache based in the Cache-Control and Expires headers.

1.5.0

03 Aug 15:12
Compare
Choose a tag to compare
  • Changed Minify middleware to accept an array of options as the second argument.