zynagent-first application framework

Back to the API reference

zyn.RateLimit#

/// A route-level PostgreSQL-backed request allowance.
pub const RateLimit = struct {
    pub const Period = rate_limit_store.Period;
    /// Returns a subject identity, or null to deny without falling back to IP.
    pub const Key = *const fn (*const Guard) ?[]const u8;

    pub const Config = struct {
        name: []const u8,
        requests: u32,
        per: Period,
        /// The maximum immediate allowance; defaults to `requests`.
        burst: ?u32 = null,
        /// Omitting this uses the trusted client address, never a forwarded header.
        key: ?Key = null,
    };
};