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 11 12 13 |
# File 'lib/stitches/allowlist_middleware.rb', line 4 def initialize(app, ={}) @app = app @configuration = [:configuration] || Stitches.configuration @except = [:except] || @configuration.allowlist_regexp unless @except.nil? || @except.is_a?(Regexp) raise ":except must be a Regexp" end end |
Instance Method Details
#call(env) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/stitches/allowlist_middleware.rb', line 14 def call(env) if @except && @except.match(env["PATH_INFO"]) @app.call(env) else do_call(env) end end |