Sha256: 21dd08bbac57cc5ab76673240aa7696fd75a328f124283a383d913526fb67c89

Contents?: true

Size: 625 Bytes

Versions: 7

Compression:

Stored size: 625 Bytes

Contents

module ActionController::VerifyHostname
  def verify_hostname(matcher=nil, &block)
    matcher ||= Proc.new
    
    before_filter do |controller|
      host = controller.request.host
      case matcher
      when String 
        next if matcher == host
      when Regexp 
        next if matcher.match(host)
      when Proc
        next if matcher.call(host)
      end

      msg = "Not on #{host}"
      
      msg += "; should have matched #{matcher.inspect}" if App.development?
        
      controller.error 404, msg + "\n"
    end
  end
end

class ActionController::Base
  extend ActionController::VerifyHostname
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
vex-0.6.2 lib/vex/action_controller/verify_hostname.rb
vex-0.4.4 lib/vex/action_controller/verify_hostname.rb
vex-0.4.2 lib/vex/action_controller/verify_hostname.rb
vex-0.3.3 lib/vex/action_controller/verify_hostname.rb
vex-0.2.9 lib/vex/action_controller/verify_hostname.rb
vex-0.2.8 lib/vex/action_controller/verify_hostname.rb
vex-0.2.7 lib/vex/action_controller/verify_hostname.rb