library server-middleware
Common interfaces for Cormy PSR-7 server middlewares
cormy/server-middleware
Common interfaces for Cormy PSR-7 server middlewares
- Tuesday, November 22, 2016
- by schnittstabil
- Repository
- 1 Watchers
- 0 Stars
- 142 Installations
- PHP
- 4 Dependents
- 0 Suggesters
- 0 Forks
- 0 Open issues
- 2 Versions
- 0 % Grown
Cormy\Server\MiddlewareInterface
, (*1)
:nut_and_bolt: Common interfaces for Cormy PSR-7 server middlewares, (*2)
Install
composer require cormy/server-middleware
Usage
use Generator;
use Cormy\Server\MiddlewareInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
class Middleware implements MiddlewareInterface
{
/**
* Process an incoming server request and return the response, optionally delegating
* to the next request handler.
*
* @param ServerRequestInterface $request
*
* @return Generator yields PSR `ServerRequestInterface` instances and returns a PSR `ResponseInterface` instance
*/
public function __invoke(ServerRequestInterface $request):Generator
{
// delegate $request to the next request handler
$response = yield $request;
// mofify the response
$response = $response->withHeader('X-PoweredBy', 'Unicorns');
return $response;
}
}
License
MIT © Michael Mayer, (*3)
dev-master
9999999-dev
Common interfaces for Cormy PSR-7 server middlewares
Sources
Download
MIT
The Requires
The Development Requires
middleware
psr
psr-7
http
request
response
http-message
cormy
0.1.0
0.1.0.0
Common interfaces for Cormy PSR-7 server middlewares
Sources
Download
MIT
The Requires
The Development Requires
middleware
psr
psr-7
http
request
response
http-message
cormy