Sha256: 4152148acde335d86bb215ed46ce8944c57957e227456f1b5c0d4acd0ce56edf
Contents?: true
Size: 844 Bytes
Versions: 8
Compression:
Stored size: 844 Bytes
Contents
module Stitches # A middleware that will skip its behavior if the path matches an allowed URL class AllowlistMiddleware def initialize(app, options={}) @app = app @configuration = options[:configuration] @except = options[:except] allowlist_regex end def call(env) if allowlist_regex && allowlist_regex.match(env["PATH_INFO"]) @app.call(env) else do_call(env) end end protected def do_call(env) raise 'subclass must implement' end def configuration @configuration || Stitches.configuration end private def allowlist_regex regex = @except || configuration.allowlist_regexp if !regex.nil? && !regex.is_a?(Regexp) raise ":except must be a Regexp" end regex end end end
Version data entries
8 entries across 8 versions & 1 rubygems