Class: Rack::Vhost

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/vhost.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, args) ⇒ Vhost

Returns a new instance of Vhost.



3
4
5
6
7
# File 'lib/rack/vhost.rb', line 3

def initialize(app, args)
  @app = app
  @sub_app = args[:app]
  @regex = Regexp.new(args[:vhost].to_s)
end

Instance Method Details

#call(env) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/rack/vhost.rb', line 9

def call(env)
  if env['HTTP_HOST'] =~ @regex
    @sub_app.call(env)
  else
    @app.call(env)
  end
end