EDA.HTTP.Bucket (EDA v0.3.0)

Copy Markdown View Source

Computes rate limit bucket keys from HTTP method and path.

Discord rate limits are per-route, but some routes share buckets based on "major parameters" (guild_id, channel_id, webhook_id). This module normalizes paths so that requests to the same bucket get the same key.

Rules

  • Guild ID, channel ID, and webhook ID are preserved (major parameters)
  • Other snowflake IDs are replaced with :id
  • DELETE on message endpoints gets a DELETE: prefix (separate bucket)

Summary

Functions

Computes a bucket key for the given HTTP method and API path.

Functions

key(method, path)

@spec key(atom(), String.t()) :: String.t()

Computes a bucket key for the given HTTP method and API path.

Examples

iex> EDA.HTTP.Bucket.key(:get, "/guilds/123/bans/456")
"/guilds/123/bans/:id"

iex> EDA.HTTP.Bucket.key(:delete, "/channels/789/messages/111")
"DELETE:/channels/789/messages/:id"