Skip to content

Commit b699e98

Browse files
miccehedinmarickvantuil
authored andcommitted
Use request header according to request type
1 parent 297c31f commit b699e98

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

src/TaskHandler.php

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,14 @@
55
use Google\ApiCore\ApiException;
66
use Google\Cloud\Tasks\V2\CloudTasksClient;
77
use Google\Cloud\Tasks\V2\RetryConfig;
8-
use Illuminate\Bus\Queueable;
98
use Illuminate\Contracts\Encryption\Encrypter;
10-
use Illuminate\Queue\Jobs\Job;
11-
use Illuminate\Queue\QueueManager;
129
use Illuminate\Queue\WorkerOptions;
1310
use Illuminate\Support\Facades\Log;
1411
use Illuminate\Support\Str;
1512
use Illuminate\Validation\ValidationException;
1613
use Safe\Exceptions\JsonException;
1714
use UnexpectedValueException;
15+
use stdClass;
1816

1917
use function Safe\json_decode;
2018

@@ -69,6 +67,7 @@ public function handle(?string $task = null): void
6967
* @param string|array|null $task
7068
* @return array
7169
* @throws JsonException
70+
* @throws ValidationException
7271
*/
7372
private function captureTask($task): array
7473
{
@@ -80,26 +79,31 @@ private function captureTask($task): array
8079
$array = [];
8180
}
8281

82+
$nameHeader = config('queue.connections.cloudtasks.app_engine')
83+
? 'X-AppEngine-TaskName'
84+
: 'X-CloudTasks-TaskName';
85+
Log::debug($nameHeader);
8386
$validator = validator([
8487
'json' => $task,
8588
'task' => $array,
86-
'name_header' => request()->header('X-CloudTasks-Taskname'),
89+
'name_header' => request()->header($nameHeader),
8790
], [
8891
'json' => 'required|json',
8992
'task' => 'required|array',
9093
'task.data' => 'required|array',
9194
'name_header' => 'required|string',
9295
]);
9396

94-
try {
95-
$validator->validate();
96-
} catch (ValidationException $e) {
97-
if (config('app.debug')) {
98-
throw $e;
99-
} else {
100-
abort(404);
101-
}
102-
}
97+
$validator->validate();
98+
// try {
99+
// $validator->validate();
100+
// } catch (ValidationException $e) {
101+
// if (config('app.debug')) {
102+
// throw $e;
103+
// } else {
104+
// abort(404);
105+
// }
106+
// }
103107

104108
return json_decode($task, true);
105109
}

0 commit comments

Comments
 (0)