Class: CodeBuddy::ShowApp

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

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ ShowApp

Returns a new instance of ShowApp.



3
4
5
6
7
# File 'lib/code_buddy/middleware.rb', line 3

def initialize(app)
  @app = app

  CodeBuddy::App.path_prefix = '/code_buddy'
end

Instance Method Details

#call(env) ⇒ Object



9
10
11
12
13
14
15
16
# File 'lib/code_buddy/middleware.rb', line 9

def call(env)
  if env['PATH_INFO'] =~ /^\/code_buddy(.*)/
    env['PATH_INFO'] = $1 #strip the code_buddy/ prefix
    CodeBuddy::App.new.call(env)
  else
    @app.call(env)
  end
end