Sha256: 1f736c63a910c96709bd84a46156ea1d422407a1591d05c822425db9e85047e0

Contents?: true

Size: 572 Bytes

Versions: 5

Compression:

Stored size: 572 Bytes

Contents

class SiteDetector
  def initialize(app)
    @app = app
  end
  
  def call(env)
    request = Rack::Request.new(env)
    site = Site.where(domains: request.host).first
    env['yodel.site'] = site
    
    unless site.nil?
      if Yodel.env.production?
        raise MissingRootDirectory.new(site, request.port) if !File.directory?(site.root_directory)
        env['rack.session.options'][:domain] = ".#{site.domains.first}"
      end
    else
      raise DomainNotFound.new(request.host, request.port) if Yodel.env.production?
    end
    
    @app.call(env)
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
yodel-0.0.7 lib/yodel/middleware/site_detector.rb
yodel-0.0.4 lib/yodel/middleware/site_detector.rb
yodel-0.0.3 lib/yodel/middleware/site_detector.rb
yodel-0.0.2 lib/yodel/middleware/site_detector.rb
yodel-0.0.1 lib/yodel/middleware/site_detector.rb