class BreezyPDF::Interceptor

Intercept a Rack request

Attributes

app[R]
env[R]

Public Class Methods

new(app, env) click to toggle source
# File lib/breezy_pdf/interceptor.rb, line 8
def initialize(app, env)
  @app = app
  @env = env
end

Public Instance Methods

intercept!() click to toggle source
# File lib/breezy_pdf/interceptor.rb, line 13
def intercept!
  if intercept?
    BreezyPDF.logger.info("[BreezyPDF] Intercepting request for PDF rendering")
    intercept.new(@app, @env).call
  else
    app.call(env)
  end
end

Private Instance Methods

get?() click to toggle source
# File lib/breezy_pdf/interceptor.rb, line 32
def get?
  env["REQUEST_METHOD"].match?(/get/i)
end
intercept() click to toggle source
# File lib/breezy_pdf/interceptor.rb, line 40
def intercept
  if BreezyPDF.treat_urls_as_private
    BreezyPDF::Intercept::PrivateUrl
  else
    BreezyPDF::Intercept::PublicUrl
  end
end
intercept?() click to toggle source
# File lib/breezy_pdf/interceptor.rb, line 24
def intercept?
  get? && matching_uri?
end
matchers() click to toggle source
# File lib/breezy_pdf/interceptor.rb, line 36
def matchers
  @matchers ||= BreezyPDF.middleware_path_matchers
end
matching_uri?() click to toggle source
# File lib/breezy_pdf/interceptor.rb, line 28
def matching_uri?
  matchers.any? { |regex| env["REQUEST_URI"].match?(regex) }
end