module Rack::Handler
Override the Rack::Handler
to bind to 0.0.0.0 which is required to support lvh.me redirects.
Public Class Methods
default(_options = {})
click to toggle source
rubocop: disable Metrics/MethodLength
# File lib/rails/local_subdomain/rack/handler.rb, line 14 def self.default(_options = {}) orig_default.instance_eval do class << self alias orig_run run end def self.run(app, options = {}) env = (options[:environment] || Rails.env) if options[:Host] == 'localhost' && Rails::LocalSubdomain.enabled_in?(env) message(options[:Port]) options[:Host] = '0.0.0.0' end orig_run(app, options) end def self.message(port) ::Logger.new(STDOUT).info( "Binding 'localhost' to '0.0.0.0' for "\ "http://lvh.me:#{port}/ support") end end orig_default end
Also aliased as: orig_default
message(port)
click to toggle source
# File lib/rails/local_subdomain/rack/handler.rb, line 31 def self.message(port) ::Logger.new(STDOUT).info( "Binding 'localhost' to '0.0.0.0' for "\ "http://lvh.me:#{port}/ support") end
run(app, options = {})
click to toggle source
# File lib/rails/local_subdomain/rack/handler.rb, line 20 def self.run(app, options = {}) env = (options[:environment] || Rails.env) if options[:Host] == 'localhost' && Rails::LocalSubdomain.enabled_in?(env) message(options[:Port]) options[:Host] = '0.0.0.0' end orig_run(app, options) end
Also aliased as: orig_run