Class: Rack::CookieRewrite
- Inherits:
-
Object
- Object
- Rack::CookieRewrite
- Defined in:
- lib/rack/cookie_rewrite.rb
Overview
Rack middleware to add an alternate header for Cookies.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, prefix) ⇒ CookieRewrite
constructor
A new instance of CookieRewrite.
Constructor Details
#initialize(app, prefix) ⇒ CookieRewrite
Returns a new instance of CookieRewrite.
6 7 8 9 |
# File 'lib/rack/cookie_rewrite.rb', line 6 def initialize(app, prefix) @app = app @prefix = prefix end |
Instance Method Details
#call(env) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/rack/cookie_rewrite.rb', line 11 def call(env) ( = env["HTTP_X_#{@prefix}_COOKIE"]) && (env['HTTP_COOKIE'] = ) status, headers, body = @app.call(env) ( = headers['Set-Cookie']) && headers["X-#{@prefix}-Set-Cookie"] = [status, headers, body] end |