class LeakyBucket::Middleware
Public Class Methods
new(app)
click to toggle source
# File lib/leaky_bucket/middleware.rb, line 5 def initialize(app) @app = app end
Public Instance Methods
call(env)
click to toggle source
# File lib/leaky_bucket/middleware.rb, line 9 def call(env) begin @app.call(env) rescue LeakyBucket::TooManyRequests => e body = "Limit exceeded" headers = { "Content-Type" => "text/plain", "Content-Length" => 14, "Retry-After" => "#{e.retry_in}" } [ 429, headers, [ body ]] end end