Skip to content

feat: add addWebhookExtraHeaders to merge with existing webhook headers#263

Open
Jean-Beru wants to merge 1 commit intosensiolabs:1.xfrom
Jean-Beru:feat/add-webhook-extra-headers
Open

feat: add addWebhookExtraHeaders to merge with existing webhook headers#263
Jean-Beru wants to merge 1 commit intosensiolabs:1.xfrom
Jean-Beru:feat/add-webhook-extra-headers

Conversation

@Jean-Beru
Copy link
Copy Markdown
Contributor

@Jean-Beru Jean-Beru commented Apr 29, 2026

Q A
Gotenberg API version ? 8.x
Bug fix ? no
New feature ? yes
BC break ? no
Issues Fix #248

Description

Adds addWebhookExtraHeaders(array $extraHttpHeaders): static to WebhookTrait, mirroring the existing extraHttpHeaders() / addExtraHttpHeaders() pair (overwrite vs. merge).

Use case: when webhook headers are already defined in bundle config (e.g. a static Authorization), callers can now append per-request headers (e.g. a correlation id) without replacing the whole set. Today, webhookExtraHeaders() always overwrites, so any caller-provided values wipe the configured ones.

The implementation reads the current Gotenberg-Webhook-Extra-Http-Headers header (stored as a JSON string in the headers bag), array_merges the new headers on top, and re-encodes by delegating to webhookExtraHeaders(). An empty array short-circuits as a no-op, matching addExtraHttpHeaders().

All 13 builders that compose WebhookTrait (10 PDF + 3 Screenshot) inherit the method via trait composition. Three test cases in WebhookTestCaseTrait (merge, empty no-op, no prior headers) are therefore exercised against every builder.

Note on naming: the issue suggests webhookAddExtraHeaders; this PR uses addWebhookExtraHeaders instead, to stay consistent with the existing extraHttpHeaders / addExtraHttpHeaders convention. Happy to rename if you'd prefer the original spelling.

Mirrors the existing extraHttpHeaders / addExtraHttpHeaders pair: when
webhook headers are already defined (e.g. an Authorization header coming
from bundle config), addWebhookExtraHeaders lets callers append per-request
headers instead of replacing the whole set.

Closes sensiolabs#248.

Assisted-by: Claude:claude-opus-4-7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Adding webhookAddExtraHeaders for pdf builder classes.

2 participants