REST Annotations
REST resources, security, throttling and logging.
Rest resource registration
| Parameter | Type | Default | Behavior |
|---|---|---|---|
| slug | string|null | null | Resource path segment; normalized by the REST Registry. |
| methods | array | ['GET'] | Allowed HTTP verbs, including GET, POST, PUT, PATCH and DELETE. |
| active | bool | true | Enable or disable resource registration. |
Apply Rest to a Collection class, not to a Document. The REST Registry discovers the resource in an active REST context; authentication and permissions still apply.
use Core\Rest\Annotation\Rest;
#[Rest(slug: 'products', methods: ['GET', 'POST'], active: true)]
class ProductCollection extends \Core\Collection\Base {}
Additional REST collection annotations
| Parameter | Type | Default | Behavior |
|---|---|---|---|
| RateLimit: limit | int | 100 | Maximum request count in a time window. |
| RateLimit: seconds | int | 60 | Window duration in seconds. |
| Security: users | array | [] | Allowed resolved Basic authentication usernames. |
| Security: keys | array | [] | Allowed resolved Bearer key identifiers, not raw tokens. |
| Log: active | bool | false | Enable request logging. |
| Log: errors | bool | true | Enable error logging. |
| Log: body | bool | false | Include request bodies in logging. |
| Log: headers | bool | false | Include request headers in logging. |
#[RateLimit(limit: 100, seconds: 60)]
#[Security(users: ['admin'], keys: ['cms-admin-api'])]
#[Log(active: true, errors: true, body: false, headers: false)]
class ProductCollection extends \Core\Collection\Base {}
Do not place raw credentials in Security metadata. Body and header logging can expose sensitive data and should remain disabled unless sanitized.