Sha256: af37c0cdcfa7614ac5d5c92d84dacae89758db6e16c06e630acba1ad7d5a46fc

Contents?: true

Size: 690 Bytes

Versions: 7

Compression:

Stored size: 690 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] ||  Stitches.configuration
      @except        = options[:except]        || @configuration.allowlist_regexp

      unless @except.nil? || @except.is_a?(Regexp)
        raise ":except must be a Regexp"
      end
    end
    def call(env)
      if @except && @except.match(env["PATH_INFO"])
        @app.call(env)
      else
        do_call(env)
      end
    end

  protected

    def do_call(env)
      raise 'subclass must implement'
    end

  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
stitches-3.8.3 lib/stitches/allowlist_middleware.rb
stitches-3.8.2 lib/stitches/allowlist_middleware.rb
stitches-3.8.1 lib/stitches/allowlist_middleware.rb
stitches-3.8.0 lib/stitches/allowlist_middleware.rb
stitches-3.7.3 lib/stitches/allowlist_middleware.rb
stitches-3.7.2 lib/stitches/allowlist_middleware.rb
stitches-3.7.0 lib/stitches/allowlist_middleware.rb