Sha256: ad723cf355e7cbdca69c087a68bbe99c071a70add2c4fc39a311b67d099839fa

Contents?: true

Size: 563 Bytes

Versions: 4

Compression:

Stored size: 563 Bytes

Contents

module Locomotive
  module Middlewares
    class Site

      def initialize(app, opts = {})
        @app = app
      end

      def call(env)
        env['locomotive.site'] = fetch_site(env)
        @app.call(env)
      end

      def fetch_site(env)
        request = Rack::Request.new(env)
        Locomotive.log "[fetch site] host = #{request.host} / #{env['HTTP_HOST']}"
        if Locomotive.config.multi_sites?
          Locomotive::Site.match_domain(request.host).first
        else
          Locomotive::Site.first
        end
      end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
locomotive_cms-2.5.7 lib/locomotive/middlewares/site.rb
locomotive_cms-2.5.6 lib/locomotive/middlewares/site.rb
locomotive_cms-2.5.6.rc2 lib/locomotive/middlewares/site.rb
locomotive_cms-2.5.6.rc1 lib/locomotive/middlewares/site.rb