Class: Rack::BetaSite

Inherits:
Object
  • Object
show all
Includes:
Utils
Defined in:
lib/bacchus/rack/beta_site.rb

Defined Under Namespace

Classes: Request

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of BetaSite.



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

def initialize(app, options = {})
  @app = app
  @excluded_routes = options[:except] || []
  @access_form_routes = options[:access_through] || []
  @access_template_route = options[:access_template] or raise "Specify the route to the template for the access form."
  base_url = options[:backend] or raise "Specify the address of the backend server."
  @backend = Bacchus::Backend.new(base_url)
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



17
18
19
# File 'lib/bacchus/rack/beta_site.rb', line 17

def options
  @options
end

Instance Method Details

#call(env) ⇒ Object



28
29
30
31
32
33
34
35
# File 'lib/bacchus/rack/beta_site.rb', line 28

def call(env)
  request = Request.new(env)
  access_pass = Bacchus::AccessPass.get(request)
  status, headers, body = respond_to(request, access_pass)
  response = Response.new(body, status, headers)
  access_pass.maybe_save(response)
  response.finish
end