Sha256: d714e79db031f2f60c75e8521946e98d10e421afcbc7a255eb57045508da8f3e
Contents?: true
Size: 1.38 KB
Versions: 8
Compression:
Stored size: 1.38 KB
Contents
module Ratchetio module Rails module ControllerMethods def ratchetio_request_data { :params => params.to_hash, :url => ratchetio_request_url, :user_ip => ratchetio_user_ip, :headers => ratchetio_request_headers, :GET => request.GET.to_hash, # leaving out POST for now :method => request.method, } end private def ratchetio_request_url url = "#{request.protocol}#{request.host}" unless [80, 443].include?(request.port) url << ":#{request.port}" end url << request.fullpath url end def ratchetio_user_ip # priority: X-Real-Ip, then X-Forwarded-For, then request.remote_ip real_ip = request.env["HTTP_X_REAL_IP"] if real_ip return real_ip end forwarded_for = request.env["HTTP_X_FORWARDED_FOR"] if forwarded_for return forwarded_for end request.remote_ip end def ratchetio_request_headers headers = {} request.env.each_pair do |k,v| if k.match(/^HTTP_/) # convert HTTP_CONTENT_TYPE to Content-Type, etc. name = k.split("_", 2)[1].sub("_", "-").split(/(\W)/).map(&:capitalize).join headers[name] = v end end headers end end end end
Version data entries
8 entries across 8 versions & 1 rubygems