Class: Rack::WWW

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

Overview

Rack::WWW

Instance Method Summary collapse

Constructor Details

#initialize(app, options = {}) ⇒ WWW

Returns a new instance of WWW.



8
9
10
11
12
13
14
15
16
17
# File 'lib/rack/www.rb', line 8

def initialize(app, options = {})
  @options = { subdomain: 'www' }.merge(options)
  @app = app

  @redirect = !@options[:www].nil? ? @options[:www] : true
  @message = @options[:message]
  @subdomain = @options[:subdomain]
  @host_regex = @options[:host_regex] || /.+/i
  @predicate = @options[:predicate]
end

Instance Method Details

#call(env) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/rack/www.rb', line 19

def call(env)
  if redirect?(env)
    redirect(env)
  else
    @app.call(env)
  end
end