Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Extracting Rack:Bug::PanelApp base class

  • Loading branch information...
commit 8206eb8e9c016908ebc493f338a5c2fef32a7929 1 parent 25de7dc
@brynary brynary authored
View
29 lib/rack/bug/panel_app.rb
@@ -0,0 +1,29 @@
+module Rack
+ module Bug
+
+ class PanelApp
+ include Rack::Bug::Render
+
+ attr_reader :request
+
+ def call(env)
+ @request = Rack::Request.new(env)
+ dispatch
+ end
+
+ def render_template(*args)
+ Rack::Response.new([super]).to_a
+ end
+
+ def params
+ @request.GET
+ end
+
+ def not_found
+ [404, {}, []]
+ end
+
+ end
+
+ end
+end
View
27 lib/rack/bug/panels/cache_panel/panel_app.rb
@@ -1,16 +1,10 @@
+require "rack/bug/panel_app"
+
module Rack
module Bug
class CachePanel
- class PanelApp
- include Rack::Bug::Render
-
- attr_reader :request
-
- def call(env)
- @request = Rack::Request.new(env)
- dispatch
- end
+ class PanelApp < ::Rack::Bug::PanelApp
def dispatch
case request.path_info
@@ -21,22 +15,10 @@ def dispatch
end
end
- def params
- request.GET
- end
-
- def not_found
- [404, {}, []]
- end
-
def ok
Rack::Response.new(["OK"]).to_a
end
- def render_template(*args)
- Rack::Response.new([super]).to_a
- end
-
def view_cache
render_template "panels/view_cache", :key => params["key"], :value => Rails.cache.read(params["key"])
end
@@ -49,12 +31,15 @@ def delete_cache
def delete_cache_list
raise "Rails not found... can't delete key" unless defined?(Rails)
+
params.each do |key, value|
next unless key =~ /^keys/
Rails.cache.delete(value)
end
+
ok
end
+
end
end
View
24 lib/rack/bug/panels/sql_panel/panel_app.rb
@@ -1,16 +1,10 @@
+require "rack/bug/panel_app"
+
module Rack
module Bug
class SQLPanel
- class PanelApp
- include Rack::Bug::Render
-
- attr_reader :request
-
- def call(env)
- @request = Rack::Request.new(env)
- dispatch
- end
+ class PanelApp < ::Rack::Bug::PanelApp
def dispatch
return not_found if secret_key.nil? || secret_key == ""
@@ -27,18 +21,6 @@ def secret_key
@request.env['rack-bug.secret_key']
end
- def params
- @request.GET
- end
-
- def not_found
- [404, {}, []]
- end
-
- def render_template(*args)
- Rack::Response.new([super]).to_a
- end
-
def validate_query_hash(query)
raise SecurityError.new("Invalid query hash") unless query.valid_hash?(secret_key, params["hash"])
end
Please sign in to comment.
Something went wrong with that request. Please try again.