class GrapeTokenAuth::Middleware
Attributes
app[R]
request_start[R]
scope[R]
Public Class Methods
new(app, _options)
click to toggle source
# File lib/grape_token_auth/middleware.rb, line 4 def initialize(app, _options) @app = app end
Public Instance Methods
call(env)
click to toggle source
# 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
Private Instance Methods
response_with_auth_headers(status, headers, response)
click to toggle source
# File lib/grape_token_auth/middleware.rb, line 34 def response_with_auth_headers(status, headers, response) auth_headers = AuthenticationHeader.new(authorizer_data, request_start) [ status, headers.merge(auth_headers.headers), response ] end
setup(env)
click to toggle source
# File lib/grape_token_auth/middleware.rb, line 29 def setup(env) @request_start = Time.now @authorizer_data = AuthorizerData.from_env(env) end