Class: Stitches::AllowlistMiddleware
- Inherits:
-
Object
- Object
- Stitches::AllowlistMiddleware
- Defined in:
- lib/stitches/allowlist_middleware.rb
Overview
A middleware that will skip its behavior if the path matches an allowed URL
Direct Known Subclasses
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ AllowlistMiddleware
constructor
A new instance of AllowlistMiddleware.
Constructor Details
#initialize(app, options = {}) ⇒ AllowlistMiddleware
Returns a new instance of AllowlistMiddleware.
4 5 6 7 8 9 10 |
# File 'lib/stitches/allowlist_middleware.rb', line 4 def initialize(app, ={}) @app = app @configuration = [:configuration] @except = [:except] allowlist_regex end |
Instance Method Details
#call(env) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/stitches/allowlist_middleware.rb', line 12 def call(env) if allowlist_regex && allowlist_regex.match(env["PATH_INFO"]) @app.call(env) else do_call(env) end end |