class BreezyPDF::Intercept::PrivateUrl
:nodoc
Public Instance Methods
call()
click to toggle source
# File lib/breezy_pdf/intercept/private_url.rb, line 6 def call raise BreezyPDF::Intercept::UnRenderable unless (200..299).cover?(status) BreezyPDF.logger.info( "[BreezyPDF] Requesting render of #{rendered_url} with metadata: #{metadata}" ) render_request = BreezyPDF::RenderRequest.new(public_url, metadata).submit BreezyPDF.logger.info("[BreezyPDF] Completed request intercept in #{timing} seconds") BreezyPDF.logger.info("[BreezyPDF] Redirect to pdf at #{render_request.download_url}") [ 302, { "Location" => render_request.download_url, "Content-Type" => "text/html", "Content-Length" => "0" }, [] ] rescue BreezyPDF::Intercept::UnRenderable BreezyPDF.logger.fatal("[BreezyPDF] Unable to render HTML, server responded with HTTP Status #{status}") response end
Private Instance Methods
body()
click to toggle source
# File lib/breezy_pdf/intercept/private_url.rb, line 62 def body @body ||= response[2].respond_to?(:body) ? response[2].body : response[2].join end
doctored_env()
click to toggle source
# File lib/breezy_pdf/intercept/private_url.rb, line 70 def doctored_env env.dup.tap do |hash| hash["HTTP_ACCEPT"] = "text/html" hash["PATH_INFO"] = path end end
headers()
click to toggle source
# File lib/breezy_pdf/intercept/private_url.rb, line 58 def headers @headers ||= response[1] end
html_private_asset()
click to toggle source
# File lib/breezy_pdf/intercept/private_url.rb, line 50 def html_private_asset @html_private_asset ||= BreezyPDF::Resources::HTML.new(base_url, body) end
metadata()
click to toggle source
Calls superclass method
BreezyPDF::Intercept::Base#metadata
# File lib/breezy_pdf/intercept/private_url.rb, line 34 def metadata super.merge( "upload_ids" => upload_ids ).merge(html_private_asset.metadata) end
public_url()
click to toggle source
# File lib/breezy_pdf/intercept/private_url.rb, line 30 def public_url @public_url ||= upload.public_url end
response()
click to toggle source
# File lib/breezy_pdf/intercept/private_url.rb, line 66 def response @response ||= app.call(doctored_env) end
status()
click to toggle source
# File lib/breezy_pdf/intercept/private_url.rb, line 54 def status @status ||= response[0] end
upload()
click to toggle source
# File lib/breezy_pdf/intercept/private_url.rb, line 44 def upload @upload ||= BreezyPDF::Uploads::Base.new( html_private_asset.filename, html_private_asset.content_type, html_private_asset.file_path ) end
upload_ids()
click to toggle source
# File lib/breezy_pdf/intercept/private_url.rb, line 40 def upload_ids [upload.id] + html_private_asset.upload_ids end