Skip to content

Commit d34ab47

Browse files
committed
wip
1 parent 57d0f57 commit d34ab47

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

docs/1-essentials/01-routing.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,26 @@ use Tempest\Router\Get;
538538
final readonly class StatelessController { /* … */ }
539539
```
540540

541+
### Custom route decorators
542+
543+
Building your own route decorators is done by implementing the {b`\Tempest\Router\RouteDecorator`} interface and marking your decorator as an attribute.
544+
545+
```php
546+
use Attribute;
547+
use Tempest\Router\RouteDecorator;
548+
549+
#[Attribute(Attribute::TARGET_METHOD | Attribute::TARGET_CLASS)]
550+
final readonly class Auth implements RouteDecorator
551+
{
552+
public function decorate(Route $route): Route
553+
{
554+
$route->middleare[] = AuthMiddleware::class;
555+
556+
return $route;
557+
}
558+
}
559+
```
560+
541561
## Responses
542562

543563
All requests to a controller action expect a response to be returned to the client. This is done by returning a `{php}View` or a `{php}Response` object.

0 commit comments

Comments
 (0)