Class: Aker::Confident::Rack

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

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Rack

Returns a new instance of Rack.



5
6
7
# File 'lib/aker/confident/rack.rb', line 5

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/aker/confident/rack.rb', line 9

def call(env)
  if Aker::Confident.pass_through?(env)
    @app.call(env)
  else
    if env['REQUEST_METHOD'] == 'POST'
      env['aker.check'].user.sign
      req = ::Rack::Request.new(env)
      [303, {"Location" => "#{req[:original]}"}, ""]
    else
      Aker::Confident::Sinatra.call(env)
    end
  end
end