Sha256: df886397f3fac6ed74ccc2656ab012ca869f4e49a0f7e3384bd31d9d0859714b

Contents?: true

Size: 689 Bytes

Versions: 5

Compression:

Stored size: 689 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

5 entries across 5 versions & 1 rubygems

Version Path
stitches-4.0.2 lib/stitches/allowlist_middleware.rb
stitches-4.1.0RC2 lib/stitches/allowlist_middleware.rb
stitches-4.0.1 lib/stitches/allowlist_middleware.rb
stitches-4.0.0 lib/stitches/allowlist_middleware.rb
stitches-4.0.0.RC1 lib/stitches/allowlist_middleware.rb