Class: Xing::DevAssets::GotoParam
- Inherits:
-
Object
- Object
- Xing::DevAssets::GotoParam
- Defined in:
- lib/xing/dev-assets/goto_param.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ GotoParam
constructor
A new instance of GotoParam.
Constructor Details
#initialize(app) ⇒ GotoParam
Returns a new instance of GotoParam.
4 5 6 |
# File 'lib/xing/dev-assets/goto_param.rb', line 4 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/xing/dev-assets/goto_param.rb', line 8 def call(env) status, headers, body = @app.call(env) default = [ status, headers, body ] request_path = env["SCRIPT_NAME"] + env["PATH_INFO"] unless env["QUERY_STRING"].nil? or env["QUERY_STRING"].empty? request_path += "&#{env["QUERY_STRING"]}" end return default unless status == 404 return default if %r(\A/(assets|fonts|system)) =~ request_path return default if /\.(xml|html|ico|txt)\z/ =~ request_path return default if /goto=/ =~ env["QUERY_STRING"] return [ 301, headers.merge("Location" => "/?goto=#{request_path}", "Content-Length" => "0"), [] ] rescue => ex require 'pp' pp ex end |