From 77744f510ede2eca5a43edb166d6009e574d9455 Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Thu, 7 Mar 2024 10:04:20 +0100 Subject: [PATCH] add upstream context to weasyprint html generation --- .../attestation_template_v2s_controller.rb | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/app/controllers/administrateurs/attestation_template_v2s_controller.rb b/app/controllers/administrateurs/attestation_template_v2s_controller.rb index e5e8783df..808763bc9 100644 --- a/app/controllers/administrateurs/attestation_template_v2s_controller.rb +++ b/app/controllers/administrateurs/attestation_template_v2s_controller.rb @@ -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