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
#[Controller("/prefix", tags(..))]— declare an HTTP controller.- Delete
#[Delete("/path")]— map a method (or free function) to an HTTPDELETEroute.- 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
#[Gateway("/path")]— declare a WebSocket gateway.- Get
#[Get("/path")]— map a method (or free function) to an HTTPGETroute.- 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
#[Injectable]— turn a struct into a zero-lock DI provider.- 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
#[Module(controllers(..), providers(..), imports(..))]— declare a unit of the application DAG.- Patch
#[Patch("/path")]— map a method (or free function) to an HTTPPATCHroute.- Post
#[Post("/path")]— map a method (or free function) to an HTTPPOSTroute.- Put
#[Put("/path")]— map a method (or free function) to an HTTPPUTroute.- 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 #[circuit_breaker(..)]— wrap a method in a circuit breaker.