Expand description
Procedural macros for arcly-http.
Six attribute macros — each emits a single, deterministic compile-time
registration. No runtime registry mutation; collection happens at link
time via inventory.
#[Injectable]on a struct → emitsProviderDescriptor+ ctor#[Module(providers(…), controllers(…), imports(…))]→ emitsModuleDescriptor#[Controller("/prefix", tags("t"))]on animplblock → walks inner items, consumes#[Get]/#[Post]/…/#[UseInterceptors]attributes on methods, emits oneRouteDescriptorper method with the controller prefix already concatenated#[Get/Post/Put/Delete/Patch("/path", …)]on a free fn → standalone route registration#[UseInterceptors(A, B)]→ wraps the handler thunk in the chain#[circuit_breaker(threshold = N, cooldown = "Ns")]on anasync fnwraps its body in a per-methodstatic CircuitBreaker
Attribute Macros§
- Audit
Log #[AuditLog(action = "…", resource = "…")]— emit one compliance audit record per invocation, keyed on the response status. Consumed by#[Controller]; pass-through marker on free fns.- Cache
Key #[CacheKey("template")]— custom key. Marker attribute; seeCacheTTL.- CacheTTL
#[CacheTTL(N)]— TTL in seconds. Marker attribute consumed by the route macro and stuffed intoRouteSpec.cache_ttl_secs. Pass-through here so the type system accepts it standalone.- Controller
- Delete
- Deprecated
#[Deprecated(sunset = "YYYY-MM-DD")]on a#[Controller]impl — adds RFC 8594Deprecation/Sunsetheaders to every response from this controller. Marker; consumed by#[Controller].- Encrypt
Fields #[EncryptFields(key = "tenant:acme", fields("ssn", "items.*.diagnosis"))]on aSerialize + Deserializestruct implementsEncryptRecord:record.seal(&vault)returns aserde_json::Valuewith the declared fields sealed (safe for any durable sink);T::unseal(value, &vault)reverses it. Useseal_with_key/KeyId::subject(...)for per-subject keys minted at runtime (crypto-shredding granularity).- Event
Consumer #[EventConsumer]on an impl block — registers every#[EventPattern]method into the link-time event registry (the messaging analogue of#[Controller]). Methods takeEventContextand returnResult<(), String>.- Event
Pattern #[EventPattern("topic")]— marks a method inside an#[EventConsumer]impl as the handler for one topic. Marker; consumed by#[EventConsumer].- Gateway
- Get
- Idempotent
#[Idempotent(ttl = "24h")]— Stripe-style Idempotency-Key handling: claim → run → store; retries replay the stored response; concurrent duplicates get 409. Consumed by#[Controller].- Injectable
- Mask
Fields #[MaskFields("email", "card:last4")]— redact these JSON response fields (plus the global Masker rules) before any durable layer sees the body. Consumed by#[Controller].- Module
- Patch
- Post
- Put
- Require
Policies #[RequirePolicies("orders.refund", …)]— ABAC route gate: every listed action must Permit under the hot-reloadable PolicyEngine (default-deny). Consumed by#[Controller].- Subscribe
#[Subscribe("event::name")]— marker consumed by the enclosing#[Gateway]walker. Pass-through so it also type-checks if a tool resolves it directly.- Timeout
#[Timeout("2s")]— route deadline; 504 + future cancellation on expiry. Consumed by#[Controller]; pass-through marker on free fns.- Transactional
#[Transactional]— wrap the handler in a database transaction on the request-tenant’s pool: commit onOk, rollback onErr/cancellation. Consumed by#[Controller]; pass-through marker on free fns.- UseInterceptors
#[UseInterceptors(A, B)]on a free fn — wraps that handler’s thunk.- Version
#[Version("v1")]on a#[Controller]impl — mounts every route under/v1/...and records the version in each RouteSpec. Marker; consumed by#[Controller].- circuit_
breaker