Class: MuckContents::Routing::Rack
- Inherits:
-
Object
- Object
- MuckContents::Routing::Rack
- Defined in:
- lib/muck-contents/rack/rack.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ Rack
constructor
A new instance of Rack.
Constructor Details
#initialize(app) ⇒ Rack
Returns a new instance of Rack.
4 5 6 |
# File 'lib/muck-contents/rack/rack.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/muck-contents/rack/rack.rb', line 8 def call(env) env["action_dispatch.show_exceptions"] = false @app.call(env) rescue => exception if exception.kind_of?(ActionController::RoutingError) request_type = File.extname(env["REQUEST_URI"]).gsub('.','').downcase # HACK. We can't rely on request.format when the request comes from ie. # request.format.html? can actually give a false result on ie so try the file extension # Requests to the content system won't have a file extension so request_type should be empty if request_type.empty? env["muck-contents.request_uri"] = env["REQUEST_URI"].gsub("http://#{env["HTTP_HOST"]}", '') env["PATH_INFO"] = env["REQUEST_URI"] = "/contents_missing" end end env["action_dispatch.show_exceptions"] = true return @app.call(env) end |