Class: BreezyPDF::Intercept::PrivateUrl

Inherits:
Base
  • Object
show all
Defined in:
lib/breezy_pdf/intercept/private_url.rb

Overview

:nodoc

Instance Attribute Summary

Attributes inherited from Base

#app, #env

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from BreezyPDF::Intercept::Base

Instance Method Details

#callObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# 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: #{}"
  )

  render_request = BreezyPDF::RenderRequest.new(public_url, ).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