Sha256: e63487b465368f3845355f2ce12d9e23d40d42f4de78b47c63a8debd6324f91e
Contents?: true
Size: 672 Bytes
Versions: 11
Compression:
Stored size: 672 Bytes
Contents
# frozen_string_literal: true module Decidim # A middleware that enhances the request with the current organization based # on the hostname. class CurrentOrganization # Initializes the Rack Middleware. # # app - The Rack application def initialize(app) @app = app end # Main entry point for a Rack Middleware. # # env - A Hash. def call(env) env["decidim.current_organization"] = detect_current_organization(env) @app.call(env) end private def detect_current_organization(env) host = Rack::Request.new(env).host.downcase Decidim::Organization.where(host: host).first end end end
Version data entries
11 entries across 11 versions & 1 rubygems