Class: GrapeTokenAuth::Middleware

Inherits:
Object
  • Object
show all
Defined in:
lib/grape_token_auth/middleware.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, _options) ⇒ Middleware

Returns a new instance of Middleware.



4
5
6
# File 'lib/grape_token_auth/middleware.rb', line 4

def initialize(app, _options)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/grape_token_auth/middleware.rb', line 8

def call(env)
  setup(env)
  begin
    response_with_auth_headers(*@app.call(env))
  rescue Unauthorized
    return unauthorized
  end
end