diff --git a/lib/travis/web/app/filter.rb b/lib/travis/web/app/filter.rb index 4fbc57ab..18eb2751 100644 --- a/lib/travis/web/app/filter.rb +++ b/lib/travis/web/app/filter.rb @@ -3,12 +3,11 @@ class Travis::Web::App autoload :Endpoint, 'travis/web/app/filter/endpoint' autoload :Assets, 'travis/web/app/filter/assets' - attr_reader :app, :config, :filters + attr_reader :app, :config def initialize(app, config) @app = app @config = config - @filters = [Endpoint.new(config), Assets.new(config)] end def call(env) @@ -27,6 +26,10 @@ class Travis::Web::App [headers, filtered] end + def filters + @filters ||= Filter.constants.map { |name| Filter.const_get(name).new(config) } + end + def content_type?(headers, type) headers.any? { |key, value| key.downcase == 'content-type' and value.start_with?(type) } end