Class: FSR::Rack::Middleware

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

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Middleware

Returns a new instance of Middleware.



8
9
10
# File 'lib/rack/middleware.rb', line 8

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/rack/middleware.rb', line 12

def call(env)
  params = ::Rack::Request.new(env)
  return @app.call(env) unless params["section"]

  path = params["section"] + "/"

  path << case path
  when "dialplan/"
    dp_req(params)
  when "directory/"
    dir_req(params)
  when "configuration/"
    conf_req(params)
  end

  env["PATH_INFO"] = "#{env['PATH_INFO']}/#{path}".squeeze('/')
  @app.call(env)
end