Skip to content

Commit ff9cf0b

Browse files
authored
Add cfray header if present (#43)
1 parent e50998b commit ff9cf0b

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/FilebeatLogging/RequestProcessor.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,19 @@ private static function clientExtras(Request $request): array
5757
*/
5858
private static function httpExtras(Request $request): array
5959
{
60+
$allowedHeaders = collect(['CF-Ray']);
61+
6062
return [
6163
'request' => [
6264
'id' => $request->header('CF-RAY'),
6365
'method' => $request->getMethod(),
66+
$allowedHeaders->reduce(function ($carry, $headerName) use ($request) {
67+
if (($headerValue = $request->header($headerName)) !== null) {
68+
$carry[$headerName] = $headerValue;
69+
}
70+
71+
return $carry;
72+
}, []),
6473
],
6574
];
6675
}

0 commit comments

Comments
 (0)