Sha256: aba8da9e612cd980419e8984b14f9b2cb2bacd5fe813d895231c8ac63c06bf3f
Contents?: true
Size: 859 Bytes
Versions: 2
Compression:
Stored size: 859 Bytes
Contents
require 'sitehub/middleware' require 'sitehub/rules' class SiteHub class Route include Middleware, Resolver, Rules, Equality attr_reader :id, :sitehub_cookie_name, :sitehub_cookie_path, :app def initialize(app, id:, sitehub_cookie_name:, sitehub_cookie_path: nil) @app = app @id = id @sitehub_cookie_name = sitehub_cookie_name @sitehub_cookie_path = sitehub_cookie_path end def call(env) request = env[REQUEST] @app.call(env).tap do |response| response.set_cookie(sitehub_cookie_name, path: resolve_sitehub_cookie_path(request), value: id) end end def resolve_sitehub_cookie_path(request) sitehub_cookie_path || request.path end def init @app = apply_middleware(@app) self end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
sitehub-0.5.0.alpha3 | lib/sitehub/middleware/route.rb |
sitehub-0.5.0.alpha2 | lib/sitehub/middleware/route.rb |