Class: SupportSegment::MobileDetect::Middleware
- Inherits:
-
Object
- Object
- SupportSegment::MobileDetect::Middleware
- Defined in:
- lib/support_segment/mobile_detect.rb
Overview
the following sucks and it makes sense to be more in control of what routes you want to expose for the mobile experience
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ Middleware
constructor
A new instance of Middleware.
Constructor Details
#initialize(app) ⇒ Middleware
Returns a new instance of Middleware.
16 17 18 |
# File 'lib/support_segment/mobile_detect.rb', line 16 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/support_segment/mobile_detect.rb', line 20 def call(env) begin request = Rack::Request.new(env) if request.host.match(/^m./) request.params[:format] = :mobile request.env["action_dispatch.request.formats"] = [Mime::Type.lookup_by_extension(:mobile)] end return @app.call(env) rescue => exception Rails.logger.fatal( "\n#{exception.class} (#{exception.}):\n " + exception.backtrace.join("\n") + "\n\n" ) raise exception end end |