Releases: oscarotero/psr7-middlewares
3.1.0
- New middleware Payload
- New middleware Uuid
3.0.1
SaveResponse: Fixed namespace resolution
3.0.0
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
- 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
Fixed clientIp middleware to get the most trusted ip from "REMOTE_ADDR" server parameter.
2.1.0
- 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
SaveResponse: only save responses with status code 200.
2.0.1
- trailingSlash: The path "/" no more will be converted to "".
- trailingSlash: Added basePath option
2.0.0
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
andExpires
headers.
1.5.0
- Changed Minify middleware to accept an array of options as the second argument.