Class: Rack::AllowFrom::Middleware

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/allow-from/middleware.rb

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Middleware

Returns a new instance of Middleware.



4
5
6
# File 'lib/rack/allow-from/middleware.rb', line 4

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/rack/allow-from/middleware.rb', line 8

def call(env)
  status, headers, body = @app.call(env)
  if valid_client?(env)
    [status, headers, body]
  else
    [403, {}, ["Unauthorized access"]]
  end
end