add upstream context to weasyprint html generation

This commit is contained in:
simon lehericey 2024-03-07 10:04:20 +01:00
parent a8f2274939
commit 77744f510e

View file

@ -20,9 +20,21 @@ module Administrateurs
format.pdf do
html = render_to_string('/administrateurs/attestation_template_v2s/show', layout: 'attestation', formats: [:html])
result = Typhoeus.post(WEASYPRINT_URL,
headers: { 'content-type': 'application/json' },
body: { html: html }.to_json)
headers = {
'Content-Type' => 'application/json',
'X-Request-Id' => Current.request_id
}
body = {
html: html,
upstream_context: {
procedure_id: @procedure.id,
path: request.path,
user_id: current_user.id
}
}.to_json
result = Typhoeus.post(WEASYPRINT_URL, headers:, body:)
send_data(result.body, filename: 'attestation.pdf', type: 'application/pdf', disposition: 'inline')
end