Class: CachableUrl::Middleware

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

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Middleware

Returns a new instance of Middleware.



4
5
6
# File 'lib/cachable_url/middleware.rb', line 4

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/cachable_url/middleware.rb', line 8

def call(env)
  if env["QUERY_STRING"] == ''
    env = env.clone
    path, query = env["PATH_INFO"].split("%1f", 2)
    query = CachableUrl.decode(query || "")
    env["PATH_INFO"] = path
    env["QUERY_STRING"] = query
    env["REQUEST_URI"] = CachableUrl.decode(env["REQUEST_URI"])
    @app.call(env)
  else
    @app.call(env)
  end
end