class DevHostMiddleware def initialize(app) @app = app end def call(env) request = Rack::Request.new(env) domain = request.params["domain"] env["HTTP_HOST"] = domain if Rails.env.development? && domain @app.call(env) end end