class Stitches::AllowlistMiddleware
A middleware that will skip its behavior if the path matches an allowed URL
Public Class Methods
new(app, options={})
click to toggle source
# File lib/stitches/allowlist_middleware.rb, line 4 def initialize(app, options={}) @app = app @configuration = options[:configuration] @except = options[:except] allowlist_regex end
Public Instance Methods
call(env)
click to toggle source
# 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
Protected Instance Methods
configuration()
click to toggle source
# File lib/stitches/allowlist_middleware.rb, line 26 def configuration @configuration || Stitches.configuration end
do_call(env)
click to toggle source
# File lib/stitches/allowlist_middleware.rb, line 22 def do_call(env) raise 'subclass must implement' end
Private Instance Methods
allowlist_regex()
click to toggle source
# File lib/stitches/allowlist_middleware.rb, line 32 def allowlist_regex regex = @except || configuration.allowlist_regexp if !regex.nil? && !regex.is_a?(Regexp) raise ":except must be a Regexp" end regex end