feat: add prefixed route
All checks were successful
JS Unit Tests / test (pull_request) Successful in 19s
Build Test / build (pull_request) Successful in 21s
PHP Unit Tests / test (pull_request) Successful in 49s

Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
2026-03-06 22:48:16 -05:00
parent a533d0dd89
commit ce5c5b3746
4 changed files with 79 additions and 10 deletions

View File

@@ -0,0 +1,26 @@
<?php
namespace KTXF\Routing\Attributes;
use Attribute;
/**
* Marks a controller method as a prefix-matched anonymous route.
*
* Unlike AnonymousRoute (exact match), this attribute matches any request
* whose path *starts with* the given $path prefix, making it suitable for
* mounting sub-frameworks (e.g. sabre/dav) under a well-known URL tree.
*
* When $absolute is true the module prefix (/m/{handle}) is NOT prepended,
* so the route is registered exactly at $path from the root.
*/
#[Attribute(Attribute::TARGET_METHOD | Attribute::TARGET_CLASS)]
class AnonymousPrefixRoute
{
public function __construct(
public readonly string $path,
public readonly string $name,
public readonly array $methods = ['GET'],
public readonly bool $absolute = false,
) {}
}