Class: Redd::Middleware
- Inherits:
-
Object
- Object
- Redd::Middleware
- Defined in:
- lib/redd/middleware.rb
Overview
Rack middleware.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, opts = {}) ⇒ Middleware
constructor
A new instance of Middleware.
Constructor Details
#initialize(app, opts = {}) ⇒ Middleware
Returns a new instance of Middleware.
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/redd/middleware.rb', line 23 def initialize(app, opts = {}) @app = app strategy_opts = opts.select { |k| %i(user_agent client_id secret redirect_uri).include?(k) } @strategy = Redd::AuthStrategies::Web.new(strategy_opts) @user_agent = opts.fetch(:user_agent, "Redd:Web Application:v#{Redd::VERSION} (by unknown)") @client_id = opts.fetch(:client_id) @redirect_uri = opts.fetch(:redirect_uri) @scope = opts.fetch(:scope, ['identity']) @duration = opts.fetch(:duration, 'permanent') @auto_refresh = opts.fetch(:auto_refresh, true) && @duration == 'permanent' @via = opts.fetch(:via, '/auth/reddit') end |
Instance Method Details
#call(env) ⇒ Object
37 38 39 40 41 |
# File 'lib/redd/middleware.rb', line 37 def call(env) # This is done for thread safety so that each thread has its own copy # of the middleware logic. dup._call(env) end |