Class: Rack::TradeTracker::Handler

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/trade_tracker/handler.rb

Constant Summary collapse

PARAMS_MAP =
{campaign_id: :c,
material_id: :m,
affiliate_id: :a,
reference: :r,
redirect_url: :u}.freeze
LOGGER_REGEX =
/logger/i

Instance Method Summary collapse

Constructor Details

#initialize(domain, path, app) ⇒ Handler

Returns a new instance of Handler.



17
18
19
20
21
# File 'lib/rack/trade_tracker/handler.rb', line 17

def initialize(domain, path, app)
  @domain = domain
  @path = path
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/rack/trade_tracker/handler.rb', line 23

def call(env)
  @env = env
  @request = Rack::Request.new(env)

  return @app.call(env) unless matches_path?

  begin
    redirect
  rescue Parameters::MissingParametersError
    redirect_to_root
  end
end