factory = new Psr17Factory(); $this->passthroughHandler = $this->handlerReturning(200); } /** * @param array $headers extra headers to set on the response (already-set CORS headers etc.) */ protected function handlerReturning(int $status, array $headers = []): RequestHandlerInterface { return new class($this->factory, $status, $headers) implements RequestHandlerInterface { /** @param array $headers */ public function __construct( private ResponseFactoryInterface $factory, private int $status, private array $headers, ) { } public function handle(ServerRequestInterface $request): ResponseInterface { $response = $this->factory->createResponse($this->status); foreach ($this->headers as $name => $value) { $response = $response->withHeader($name, $value); } return $response; } }; } }