Class: WurflCloud::Rack::CacheManager
- Inherits:
-
Object
- Object
- WurflCloud::Rack::CacheManager
- Defined in:
- lib/wurfl_cloud/rack/cache_manager.rb
Constant Summary collapse
- COOKIE_NAME =
to be refactored: make configurable
'WurflCloud_Client'
- EXPIRY =
86400
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ CacheManager
constructor
A new instance of CacheManager.
Constructor Details
#initialize(app, options = {}) ⇒ CacheManager
Returns a new instance of CacheManager.
11 12 13 |
# File 'lib/wurfl_cloud/rack/cache_manager.rb', line 11 def initialize(app, ={}) @app = app end |
Instance Method Details
#call(env) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/wurfl_cloud/rack/cache_manager.rb', line 14 def call(env) # extract cookie request = Rack::Request.new(env) env['wurfl.cookie.device_cache'] = (request.) # execute upstream request status, headers, body = @app.call(env) # store cookie response = Rack::Response.new body, status, headers response.(COOKIE_NAME, {:value => {'date_set'=>Time.now.to_i, 'capabilities'=>env['wurfl.cookie.device_cache']}.to_json, :path => "/", :expires => Time.now+EXPIRY}) response.finish end |