Class: Rodauth::Rails::Middleware

Inherits:
Object
  • Object
show all
Defined in:
lib/rodauth/rails/middleware.rb

Overview

Middleware that’s added to the Rails middleware stack. Normally the main Roda app could be used directly, but this trick allows the app class to be reloadable.

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Middleware

Returns a new instance of Middleware.



7
8
9
# File 'lib/rodauth/rails/middleware.rb', line 7

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/rodauth/rails/middleware.rb', line 11

def call(env)
  app = Rodauth::Rails.app.new(@app)

  # allow the Rails app to call Rodauth methods that throw :halt
  catch(:halt) do
    app.call(env)
  end
end