stackkit / laravel-google-cloud-tasks-queue

Use Google Cloud Tasks as the queue driver for Laravel
MIT License
68 stars 36 forks source link

Feature request: ability to set request headers on HTTP jobs #123

Closed benjamin-smith closed 5 months ago

benjamin-smith commented 10 months ago

Currently, this package does not support configuring the HTTP request headers of Tasks. These headers are sent along with the HTTP request to the Laravel backend to run a given job.

My use case is for authentication, as my backend requires a secret header to be passed. Basic auth could be another use case.

More info on the headers option for Tasks: https://cloud.google.com/tasks/docs/reference/rest/v2/projects.locations.queues.tasks#httprequest

Possible implementation:

This could happen near where other properties of the Task are formed, such as the URL and HTTP Method: https://github.com/stackkit/laravel-google-cloud-tasks-queue/blob/508d1ca934d74c2c31d564f385852b2a49350ab5/src/CloudTasksQueue.php#L139-L141

$httpRequest->setHeaders(['x-my-header' => 'my-value']);

I am not sure where those headers could be defined, as ENV vars might be cumbersome. I imagine a global set of headers would be fine to be added to all Tasks, rather than per-task or per-queue headers.

marickvantuil commented 5 months ago

Hi, just letting you know that this feature was added in version 4.x of the package!

benjamin-smith commented 5 months ago

Awesome, thank you!