Module: Rack::Handler
- Defined in:
- lib/rails/local_subdomain/rack/handler.rb
Overview
Override the Rack::Handler to bind to 0.0.0.0 which is required to support lvh.me redirects.
Class Method Summary collapse
-
.default(_options = {}) ⇒ Object
rubocop: disable Metrics/MethodLength.
- .orig_default ⇒ Object
Class Method Details
.default(_options = {}) ⇒ Object
rubocop: disable Metrics/MethodLength
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 |
# File 'lib/rails/local_subdomain/rack/handler.rb', line 14 def self.default( = {}) orig_default.instance_eval do class << self alias orig_run run end def self.run(app, = {}) env = ([:environment] || Rails.env) if [:Host] == 'localhost' && Rails::LocalSubdomain.enabled_in?(env) ([:Port]) [:Host] = '0.0.0.0' end orig_run(app, ) end def self.(port) ::Logger.new(STDOUT).info( "Binding 'localhost' to '0.0.0.0' for "\ "http://lvh.me:#{port}/ support") end end orig_default end |
.orig_default ⇒ Object
10 |
# File 'lib/rails/local_subdomain/rack/handler.rb', line 10 alias orig_default default |