Class: Stitches::AllowlistMiddleware

Inherits:
Object
  • Object
show all
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

ApiKey, ValidMimeType

Instance Method Summary collapse

Constructor Details

#initialize(app, options = {}) ⇒ AllowlistMiddleware

Returns a new instance of AllowlistMiddleware.



4
5
6
7
8
9
10
# File 'lib/stitches/allowlist_middleware.rb', line 4

def initialize(app, options={})
  @app           = app
  @configuration = options[:configuration]
  @except        = options[:except]

  allowlist_regex
end

Instance Method Details

#call(env) ⇒ Object



12
13
14
15
16
17
18
# 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