make filters pluggable
This commit is contained in:
parent
7b47863014
commit
5166e65e84
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user