class Rack::CommonCookies
Rack
middleware to use common cookies across domain and subdomains.
Constants
- DOMAIN_REGEXP
- LOCALHOST_OR_IP_REGEXP
- PORT
Public Class Methods
new(app)
click to toggle source
# File lib/rack/contrib/common_cookies.rb 10 def initialize(app) 11 @app = app 12 end
Public Instance Methods
call(env)
click to toggle source
# File lib/rack/contrib/common_cookies.rb 14 def call(env) 15 status, headers, body = @app.call(env) 16 headers = Utils::HeaderHash.new(headers) 17 18 host = env['HTTP_HOST'].sub PORT, '' 19 share_cookie(headers, host) 20 21 [status, headers, body] 22 end
Private Instance Methods
domain(host)
click to toggle source
# File lib/rack/contrib/common_cookies.rb 26 def domain(host) 27 host =~ DOMAIN_REGEXP 28 ".#{$1}.#{$2}" 29 end