Class: Miso::Rewrite

Inherits:
Object
  • Object
show all
Defined in:
lib/miso/rewrite.rb

Overview

Rack middleware that intercept request to the Rack application rewrite the path so that is seems to target the base URL.

Constant Summary collapse

@@REWRITE =

Request env variable to rewrite.

['REQUEST_PATH', 'PATH_INFO', 'REQUEST_URI']

Instance Method Summary collapse

Constructor Details

#initialize(app, option) ⇒ Rewrite

Receive the app and the option list (for now only the :app_path).



9
10
11
12
# File 'lib/miso/rewrite.rb', line 9

def initialize (app, option)
  @app = app
  @path = option[:app_path]
end

Instance Method Details

#call(env) ⇒ Object

Execute request.



15
16
17
18
19
# File 'lib/miso/rewrite.rb', line 15

def call(env)
  rewritePath(env)
  status, headers, response = @app.call(env)
  [status, headers, response]
end