Sha256: c2564b8d57041fff2e3fbc2e619978ee0877df81b1089447ef465df3cc350fab

Contents?: true

Size: 833 Bytes

Versions: 15

Compression:

Stored size: 833 Bytes

Contents

module Simplec
  class Subdomains
    def self.matches?(request)
      simplec = request.headers['HTTP_X_ENGINE'] == 'simplec'
      present = request.subdomain.present?
      not_admin = request.subdomain != 'admin'
      subdomain = Simplec::Subdomain.find_by(name: request.subdomain)

      match = simplec || (present && not_admin && subdomain)

      if match
        Thread.current[:simplec_subdomain] = subdomain
        Rails.logger.info <<-LOG
Simplec request received.
  ActionDispatch::Request#original_url: #{request.original_url}
  Simplec Engine: #{not_admin}
  LOG
      else
        Rails.logger.info <<-LOG
Simplec Subdomain '#{request.subdomain}' was not found.
  ActionDispatch::Request#original_url: #{request.original_url}
  'admin' subdomain bypass: #{!not_admin}
  LOG
      end

      match
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
simplec-0.9.2 app/constraints/simplec/subdomains.rb
simplec-0.9.1 app/constraints/simplec/subdomains.rb
simplec-0.9.0 app/constraints/simplec/subdomains.rb
simplec-0.8.1 app/constraints/simplec/subdomains.rb
simplec-0.8.0 app/constraints/simplec/subdomains.rb
simplec-0.7.1 app/constraints/simplec/subdomains.rb
simplec-0.7.0 app/constraints/simplec/subdomains.rb
simplec-0.6.0 app/constraints/simplec/subdomains.rb
simplec-0.5.0 app/constraints/simplec/subdomains.rb
simplec-0.4.4 app/constraints/simplec/subdomains.rb
simplec-0.4.3 app/constraints/simplec/subdomains.rb
simplec-0.4.2 app/constraints/simplec/subdomains.rb
simplec-0.4.1 app/constraints/simplec/subdomains.rb
simplec-0.4.0 app/constraints/simplec/subdomains.rb
simplec-0.3.0 app/constraints/simplec/subdomains.rb