Class: OAuth2::Provider::Rack::Middleware
- Inherits:
-
Object
- Object
- OAuth2::Provider::Rack::Middleware
- Defined in:
- lib/oauth2/provider/rack/middleware.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
- #handle_access_token_request(env) ⇒ Object
-
#initialize(app) ⇒ Middleware
constructor
A new instance of Middleware.
Constructor Details
#initialize(app) ⇒ Middleware
Returns a new instance of Middleware.
3 4 5 |
# File 'lib/oauth2/provider/rack/middleware.rb', line 3 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/oauth2/provider/rack/middleware.rb', line 7 def call(env) request = env['oauth2'] = ResourceRequest.new(env) response = catch :oauth2 do if request.path == "/oauth/access_token" handle_access_token_request(env) else @app.call(env) end end rescue InvalidRequest => e [400, {}, e.] end |
#handle_access_token_request(env) ⇒ Object
21 22 23 |
# File 'lib/oauth2/provider/rack/middleware.rb', line 21 def handle_access_token_request(env) AccessTokenHandler.new(@app, env).process end |