Class: Warden::JWTAuth::Middleware::TokenDispatcher

Inherits:
Warden::JWTAuth::Middleware show all
Defined in:
lib/warden/jwt_auth/middleware/token_dispatcher.rb

Overview

Dispatches a token (adds it to ‘Authorization` response header) if it has been added to the request `env` by [Hooks]

Constant Summary collapse

ENV_KEY =

Debugging key added to ‘env`

'warden-jwt_auth.token_dispatcher'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ TokenDispatcher

Returns a new instance of TokenDispatcher.



14
15
16
# File 'lib/warden/jwt_auth/middleware/token_dispatcher.rb', line 14

def initialize(app)
  @app = app
end

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.



12
13
14
# File 'lib/warden/jwt_auth/middleware/token_dispatcher.rb', line 12

def app
  @app
end

Instance Method Details

#call(env) ⇒ Object



18
19
20
21
22
23
# File 'lib/warden/jwt_auth/middleware/token_dispatcher.rb', line 18

def call(env)
  env[ENV_KEY] = true
  status, headers, response = app.call(env)
  headers = headers_with_token(env, headers)
  [status, headers, response]
end