Sha256: 3ecb7d104376d47f8403822226d11735a5ab8b65f282e4e19813dabd9412217f

Contents?: true

Size: 1.39 KB

Versions: 7

Compression:

Stored size: 1.39 KB

Contents

module RooOnRails
  module Railties
    class HTTP < Rails::Railtie
      initializer 'roo_on_rails.http' do |app|
        $stderr.puts 'initializer roo_on_rails.http'
        require 'rack/timeout/base'
        require 'rack/ssl-enforcer'

        require 'roo_on_rails/rack/safe_timeouts'

        ::Rack::Timeout.service_timeout = ENV.fetch('RACK_SERVICE_TIMEOUT', 15).to_i
        ::Rack::Timeout.wait_timeout = ENV.fetch('RACK_WAIT_TIMEOUT', 30).to_i
        ::Rack::Timeout::Logger.level = Logger::WARN

        app.config.middleware.insert_before(
          ::Rack::Runtime,
          ::Rack::Timeout
        )

        middleware_to_insert_before = Rails::VERSION::MAJOR < 4 ? ::ActionDispatch::Cookies : ::Rack::Head 

        # This needs to be inserted low in the stack, before Rails returns the
        # thread-current connection to the pool.
        app.config.middleware.insert_before(
          middleware_to_insert_before,
          RooOnRails::Rack::SafeTimeouts
        )

        if ENV.fetch('ROO_ON_RAILS_RACK_DEFLATE', 'YES').to_s =~ /\A(YES|TRUE|ON|1)\Z/i
          app.config.middleware.use ::Rack::Deflater
        end

        # Don't use SslEnforcer in test environment as it breaks Capybara
        unless Rails.env.test?
          app.config.middleware.insert_before(
            middleware_to_insert_before,
            ::Rack::SslEnforcer
          )
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
roo_on_rails-1.10.0 lib/roo_on_rails/railties/http.rb
roo_on_rails-1.9.0 lib/roo_on_rails/railties/http.rb
roo_on_rails-1.8.1 lib/roo_on_rails/railties/http.rb
roo_on_rails-1.8.0 lib/roo_on_rails/railties/http.rb
roo_on_rails-1.7.0 lib/roo_on_rails/railties/http.rb
roo_on_rails-1.6.0 lib/roo_on_rails/railties/http.rb
roo_on_rails-1.5.0 lib/roo_on_rails/railties/http.rb