diff options
| author | Brett Parson <brett@brett-parson.com> | 2026-08-21 13:55:37 -0500 |
|---|---|---|
| committer | Brett Parson <brett@brett-parson.com> | 2026-08-21 14:00:11 -0500 |
| commit | d039a5d62a9ac6ababae70d9d96422ca59f2b2d4 (patch) | |
| tree | f0db4750a571e8040a5da02cc7190079c0d62914 /src/Http | |
| parent | 0de77a6334cee1f6e15f7e0fd35602514560be33 (diff) | |
| download | miniroute-d039a5d62a9ac6ababae70d9d96422ca59f2b2d4.tar.gz miniroute-d039a5d62a9ac6ababae70d9d96422ca59f2b2d4.zip | |
Scaffold miniroute routing/middleware kernel
Diffstat (limited to 'src/Http')
| -rw-r--r-- | src/Http/RequestInterface.php | 31 | ||||
| -rw-r--r-- | src/Http/ResponseInterface.php | 17 |
2 files changed, 48 insertions, 0 deletions
diff --git a/src/Http/RequestInterface.php b/src/Http/RequestInterface.php new file mode 100644 index 0000000..fe54667 --- /dev/null +++ b/src/Http/RequestInterface.php @@ -0,0 +1,31 @@ +<?php + +declare(strict_types=1); + +namespace BrettParson\MiniRoute\Http; + +/** + * Minimal HTTP request contract the router needs. + * + * Applications keep their own concrete Request class and implement this + * interface. The router only reads method/path and injects route parameters + * via withParams(); everything else stays application-owned. + */ +interface RequestInterface +{ + public function method(): string; + + public function path(): string; + + /** + * Get a route parameter extracted by the router (e.g. {slug}). + */ + public function param(string $name, string $default = ''): string; + + /** + * Return a copy of the request with route parameters attached. + * + * @param array<string, string> $params + */ + public function withParams(array $params): RequestInterface; +} diff --git a/src/Http/ResponseInterface.php b/src/Http/ResponseInterface.php new file mode 100644 index 0000000..cb74ea0 --- /dev/null +++ b/src/Http/ResponseInterface.php @@ -0,0 +1,17 @@ +<?php + +declare(strict_types=1); + +namespace BrettParson\MiniRoute\Http; + +interface ResponseInterface +{ + public function status(): int; + + public function body(): string; + + /** + * Return a copy of the response with an additional (or overridden) header. + */ + public function withHeader(string $name, string $value): ResponseInterface; +} |
