Use throttling data to set rate limit headers
mainWhen a rule triggers a throttle, the data map contains useful information for generating HTTP headers. Specifically:
data[:limit]: The maximum allowed requests.data[:remaining]: The number of requests remaining in the current window.data[:expires_at]: The expiration time in Unix time milliseconds. To use this in the standardX-Ratelimit-Resetheader, you must convert it to seconds by dividing by 1,000.
defp add_throttling_headers(conn, data) do
# Convert milliseconds to seconds for the reset header
reset = div(data[:expires_at], 1_000)
conn
|> put_resp_header("x-ratelimit-limit", to_string(data[:limit]))
|> put_resp_header("x-ratelimit-remaining", to_string(data[:remaining]))
|> put_resp_header("x-ratelimit-reset", to_string(reset))
end