for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Northwoods\Broker;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\RequestHandlerInterface;
class PathPrefixingHandler implements RequestHandlerInterface
{
/** @var RequestHandlerInterface */
private $wrapped;
/** @var string */
private $prefix;
public function __construct(RequestHandlerInterface $wrapped, $prefix)
$this->wrapped = $wrapped;
$this->prefix = $prefix;
}
/**
* Handle the request and return a response.
*/
public function handle(ServerRequestInterface $request): ResponseInterface
$uri = $request->getUri();
return $this->wrapped->handle(
$request->withUri(
$uri->withPath(
$this->prefix . $uri->getPath()
)
);