Class: L402Middleware::Middleware
- Inherits:
-
Object
- Object
- L402Middleware::Middleware
- Defined in:
- lib/l402_middleware.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, config = nil) ⇒ Middleware
constructor
A new instance of Middleware.
Constructor Details
#initialize(app, config = nil) ⇒ Middleware
Returns a new instance of Middleware.
16 17 18 19 20 21 22 23 |
# File 'lib/l402_middleware.rb', line 16 def initialize(app, config = nil) @app = app @config = L402Middleware::Configuration.new(config || default_config) @config.validate! verify_connect end |
Instance Method Details
#call(env) ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/l402_middleware.rb', line 25 def call(env) token = extract_auth_token(env) is_valid_l402_token, err = valid_l402_token?(token) if free?(env['REQUEST_PATH'].to_s) || (is_valid_l402_token.to_s == "true" && err.nil?) return allow_request(env) end invoke_payment(env[L402_AUTHORIZATION_HEADER].present?) end |