Class: AccountMiddleware

Inherits:
Object
  • Object
show all
Defined in:
lib/generators/authentication/templates/lib/account_middleware.rb

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ AccountMiddleware

Returns a new instance of AccountMiddleware.



2
3
4
# File 'lib/generators/authentication/templates/lib/account_middleware.rb', line 2

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/generators/authentication/templates/lib/account_middleware.rb', line 6

def call(env)
  request = ActionDispatch::Request.new(env)

  if m = /\A(\/(\d{1,}))/.match(request.path_info)
    script_name, , path_info = [m[1], m[2], m.post_match]
    request.script_name = script_name
    request.path_info   = path_info.presence || "/"
    ()
    @app.call(request.env)
  else
    @app.call(request.env)
  end
end