Class: Track302::RedirectController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Track302::RedirectController
- Defined in:
- app/controllers/track302/redirect_controller.rb
Constant Summary collapse
- WHITELIST =
Regexp.new(ENV.fetch('TRACK302_CLICK_DATA_MATCH', 'HTTP_USER_AGENT|HTTP_REFERER|REMOTE_ADDR'))
Instance Method Summary collapse
Instance Method Details
#show ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'app/controllers/track302/redirect_controller.rb', line 7 def show filtered_env = request.env.inject({}) {|sum, (k,v)| (WHITELIST.match(k) ? sum.merge(k => v) : sum) } if link = Link.find_by(uuid: params[:uuid]) Click.create(uuid: params[:uuid], data: filtered_env) redirect_to link.original else render nothing: true, status: 404 end end |