Class: Rack::BearerAuth::Middleware
- Inherits:
-
Object
- Object
- Rack::BearerAuth::Middleware
- Defined in:
- lib/rack/bearer_auth/middleware.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, &block) ⇒ Middleware
constructor
A new instance of Middleware.
- #match(path: nil, via: nil, token: nil, &block) ⇒ Object
Constructor Details
#initialize(app, &block) ⇒ Middleware
Returns a new instance of Middleware.
9 10 11 12 13 14 15 16 |
# File 'lib/rack/bearer_auth/middleware.rb', line 9 def initialize(app, &block) raise ArgumentError, "Block argument is required." unless block_given? @app = app @match_patterns = [] instance_exec(&block) end |
Instance Method Details
#call(env) ⇒ Object
18 19 20 21 22 |
# File 'lib/rack/bearer_auth/middleware.rb', line 18 def call(env) req = Request.new(env) handle(req) || @app.call(env) end |
#match(path: nil, via: nil, token: nil, &block) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/rack/bearer_auth/middleware.rb', line 24 def match(path: nil, via: nil, token: nil, &block) if block_given? warn "Token paramter is ignored." if token token = block end @match_patterns << MatchPattern.new(path, via, token) end |