chore: complete update
This commit is contained in:
32
src/Framework/Http/MiddlewareContext.php
Normal file
32
src/Framework/Http/MiddlewareContext.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Framework\Http;
|
||||
|
||||
/**
|
||||
* Kontextobjekt, das durch die Middleware-Kette weitergegeben wird.
|
||||
* Es enthält sowohl den ursprünglichen Request als auch eine optionale Response.
|
||||
*/
|
||||
final readonly class MiddlewareContext
|
||||
{
|
||||
public function __construct(
|
||||
public Request $request,
|
||||
public ?Response $response = null,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Erstellt einen neuen Kontext mit der gleichen Anfrage, aber einer anderen Antwort
|
||||
*/
|
||||
public function withResponse(Response $response): self
|
||||
{
|
||||
return new self($this->request, $response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prüft, ob bereits eine Response im Kontext vorhanden ist
|
||||
*/
|
||||
public function hasResponse(): bool
|
||||
{
|
||||
return $this->response !== null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user