class IpRestriction::Middleware

Public Class Methods

new(app) click to toggle source
# File lib/ip_restriction/middleware.rb, line 5
def initialize(app)
  @app = app
end

Public Instance Methods

call(env) click to toggle source
# File lib/ip_restriction/middleware.rb, line 9
def call(env)
  constraint = Constraint.instance

  if constraint.checker.allowed?(env["REMOTE_ADDR"])
    @app.call(env)
  else
    [404, {'Content-Type' => 'text/html'}, ['Not found!']]
  end
end