mirror of
https://github.com/usetrmnl/byos_laravel.git
synced 2026-01-13 15:07:49 +00:00
feat: add header support for plugin data polling
This commit is contained in:
parent
a45684d940
commit
282fdac583
3 changed files with 72 additions and 34 deletions
|
|
@ -42,7 +42,20 @@ class Plugin extends Model
|
|||
public function updateDataPayload(): void
|
||||
{
|
||||
if ($this->data_strategy === 'polling' && $this->polling_url) {
|
||||
$response = Http::withHeaders(['User-Agent' => 'usetrmnl/byos_laravel', 'Accept' => 'application/json'])
|
||||
// Parse headers from polling_header string
|
||||
$headers = ['User-Agent' => 'usetrmnl/byos_laravel', 'Accept' => 'application/json'];
|
||||
|
||||
if ($this->polling_header) {
|
||||
$headerLines = explode("\n", trim($this->polling_header));
|
||||
foreach ($headerLines as $line) {
|
||||
$parts = explode(':', $line, 2);
|
||||
if (count($parts) === 2) {
|
||||
$headers[trim($parts[0])] = trim($parts[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$response = Http::withHeaders($headers)
|
||||
->get($this->polling_url)
|
||||
->json();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue