Class: Rack::PactBroker::UIRequestFilter

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/pact_broker/ui_request_filter.rb

Constant Summary collapse

WEB_ASSET_EXTENSIONS =
%w[.js .woff .woff2 .css .png .html .map .ttf .ico].freeze
API_CONTENT_TYPES =
%w[application/hal+json application/json text/csv application/yaml].freeze

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ UIRequestFilter

Returns a new instance of UIRequestFilter.



13
14
15
# File 'lib/rack/pact_broker/ui_request_filter.rb', line 13

def initialize app
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/rack/pact_broker/ui_request_filter.rb', line 17

def call env
  if request_for_api(env) || no_accept_header(env) || (accept_all(env) && !is_web_extension(env))
    # send the request on to the next app in the Rack::Cascade
    [404, {},[]]
  else
    @app.call(env)
  end
end