Class: Attio::RateLimitMiddleware

Inherits:
Object
  • Object
show all
Defined in:
lib/attio/rate_limiter.rb

Overview

Middleware for automatic rate limiting

Since:

  • 1.0.0

Instance Method Summary collapse

Constructor Details

#initialize(app, rate_limiter) ⇒ RateLimitMiddleware

Returns a new instance of RateLimitMiddleware.

Since:

  • 1.0.0



199
200
201
202
# File 'lib/attio/rate_limiter.rb', line 199

def initialize(app, rate_limiter)
  @app = app
  @rate_limiter = rate_limiter
end

Instance Method Details

#call(env) ⇒ Object

Since:

  • 1.0.0



204
205
206
207
208
209
210
# File 'lib/attio/rate_limiter.rb', line 204

def call(env)
  @rate_limiter.execute do
    response = @app.call(env)
    # Headers are automatically updated within execute block
    response
  end
end