Sha256: d1a2a7b0a2598ed63a9a79777568cb0c4ab81af673cf0ba34918189fc48f575c
Contents?: true
Size: 1.77 KB
Versions: 1
Compression:
Stored size: 1.77 KB
Contents
module Rack::Insight class RequestVariablesPanel < Panel def after(env,status,headers,body) sections = {} sections["GET"] = sort(@request.GET) if @request.GET.any? sections["POST"] = sort(@request.POST) if @request.POST.any? # TODO: Fix for Rails 4 (as part of splitting panels into separate gems) unless defined?(ActionDispatch::Request::Session) sections["Session"] = sort(@request.env["rack.session"]) if @request.env["rack.session"] && @request.env["rack.session"].any? end sections["Cookies"] = sort(@request.env["rack.request.cookie_hash"]) if @request.env["rack.request.cookie_hash"] && @request.env["rack.request.cookie_hash"].any? server, rack = split_and_filter_env(@env) sections["SERVER VARIABLES"] = sort(server) sections["Rack ENV"] = sort(rack) # require 'pp' # ::File.open("sections.dump", "w") do |file| # PP.pp(sections, file) # end store(env, sections) end def heading "Rack Env" end def content_for_request(number) sections = retrieve(number).first render_template "panels/request_variables", :sections => sections end private def sort(hash) scrub(hash.sort_by { |k, v| k.to_s }) end def scrub(enum) enum.map do |k,v| if Hash === v [k, v.inspect] else [k, v.to_s] end end end def split_and_filter_env(env) server, rack = {}, {} env.each do |k,v| if k.index("rack.") == 0 rack[k] = v elsif k.index("rack-insight") == 0 or k.index("rack-insight") == 0 #don't output the insight variables - especially secret_key else server[k] = v end end return server, rack end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rack-insight-0.5.28 | lib/rack/insight/panels/request_variables_panel.rb |