class Rack::Relations::Middleware

Attributes

app[RW]
processor[RW]

Public Class Methods

new(app, safelist_domains: []) click to toggle source
# File lib/rack/relations/middleware.rb, line 6
def initialize(app, safelist_domains: [])
  @app = app
  @processor = Rack::Relations::Processor.new(safelist_domains: safelist_domains)
end

Public Instance Methods

call(env) click to toggle source
# File lib/rack/relations/middleware.rb, line 11
def call(env)
  status, headers, response = @app.call(env)

  response = @processor.perform(response) if headers["Content-Type"].to_s.include?("text/html")

  [status, headers, response]
end