Sha256: 63fe99abc1dfea9263f3487fdd4c8833061f2d0f1ed48bf768a7f1e9eb49e5cd

Contents?: true

Size: 631 Bytes

Versions: 1

Compression:

Stored size: 631 Bytes

Contents

module ActionController::VerifyHostname

  def self.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

1 entries across 1 versions & 1 rubygems

Version Path
vex-0.2.6 lib/vex/action_controller/verify_hostname.rb