Class: FayeRails::Middleware
- Inherits:
-
Object
- Object
- FayeRails::Middleware
- Defined in:
- lib/faye-rails/middleware.rb
Constant Summary collapse
- DEFAULTS =
{ :mount => '/faye', :timeout => 25, :extensions => nil, :engine => nil, :ping => nil, :server => 'thin' }
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}, &block) ⇒ Middleware
constructor
A new instance of Middleware.
Constructor Details
#initialize(app, options = {}, &block) ⇒ Middleware
Returns a new instance of Middleware.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/faye-rails/middleware.rb', line 13 def initialize(app, ={}, &block) @app = app if Rails.application.config.middleware.include? Rack::Lock = <<-EOF WARNING: You have the Rack::Lock middlware enabled. faye-rails can't work when Rack::Lock is enabled, as it will cause a deadlock on every request. Please add: config.middleware.delete Rack::Lock to your application config in application.rb EOF Rails.logger.fatal $stdout.puts exit 1 end = .keys - DEFAULTS.keys if .one? raise ArgumentError, "Unknown option: #{.first}." elsif .any? raise ArgumentError, "Unknown options: #{ * ", "}." end = DEFAULTS.merge() server = .delete(:server) Faye::WebSocket.load_adapter(server) if server && server != 'passenger' @adapter = FayeRails::RackAdapter.new(@app, ) @adapter.instance_eval(&block) if block.respond_to? :call end |
Instance Method Details
#call(env) ⇒ Object
51 52 53 |
# File 'lib/faye-rails/middleware.rb', line 51 def call(env) @adapter.call(env) end |