class Springcm::Middleware::RateLimit
Attributes
options[R]
Public Class Methods
new(app, options={})
click to toggle source
# File lib/springcm-sdk/middleware/rate_limit.rb, line 6 def initialize(app, options={}) @app = app @options = options end
Public Instance Methods
call(env)
click to toggle source
# File lib/springcm-sdk/middleware/rate_limit.rb, line 11 def call(env) @app.call(env).on_complete do |response_env| return response_env if response_env[:response].env.response_headers["Content-Type"] != "application/json" body = JSON.parse(response_env[:body]) if body.fetch("Error", {}).fetch("ErrorCode", nil) == 103 raise Springcm::RateLimitExceededError.new end end end