Sha256: add9b52172812686c14b869dfeeb36efd539f3ad8974cc1d8ad8ac7d1f8349ba
Contents?: true
Size: 1.01 KB
Versions: 20
Compression:
Stored size: 1.01 KB
Contents
begin require "rack" rescue LoadError end if defined?(::Rack::Request) module Timber module Util class Request < ::Rack::Request def body_content content = body.read body.rewind content end def headers @headers ||= ::Hash[*@env.select {|k,v| k.start_with? 'HTTP_'} .collect {|k,v| [k.sub(/^HTTP_/, ''), v]} .collect {|k,v| [k.split('_').collect(&:capitalize).join('-'), v]} .sort .flatten] end def ip @ip ||= if @env["action_dispatch.remote_ip"] @env["action_dispatch.remote_ip"].to_s || super else super end end def referer # Rails 3.X returns "/" for some reason @referer ||= super == "/" ? nil : super end def request_id @request_id ||= @env["action_dispatch.request_id"] || @env["X-Request-ID"] || @env["X-Request-Id"] end end end end end
Version data entries
20 entries across 20 versions & 1 rubygems