PHP code example of hakone / untouchable-psr7
1. Go to this page and download the library: Download hakone/untouchable-psr7 library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
hakone / untouchable-psr7 example snippets
use Hakone\Http\Message\UntouchableResponse;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\RequestHandlerInterface;
final class AddAttributeMiddleware
{
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
$request = $request->withAttribute('foo', 'bar');
// The handler may return UntouchableResponse. Do not call methods on it.
return $handler->handle($request);
}
}