Refactor event forwarding and improve test coverage #1
No files matched your search
+1
-1
@@ -26,7 +26,7 @@ Route::post('api/event', function (Request $request) {
|
||||
}
|
||||
|
||||
$headers = collect($request->headers->all())
|
||||
->mapWithKeys(fn($value, $key) => [$key => is_array($value) ? implode(', ', $value) : $value])
|
||||
->mapWithKeys(fn ($value, $key) => [$key => is_array($value) ? implode(', ', $value) : $value])
|
||||
->all();
|
||||
|
||||
Http::withHeaders($headers)->post(config('plausible-proxy.domain').'/api/event', $data);
|
||||
|
||||
@@ -56,11 +56,11 @@ it('accepts valid event data and forwards headers', function () {
|
||||
'https://plausible.io/api/event' => function ($request) {
|
||||
dump($request->headers());
|
||||
dump($request->data());
|
||||
|
||||
return Http::response(['status' => 'queued'], 200);
|
||||
},
|
||||
]);
|
||||
|
||||
|
||||
$headers = [
|
||||
'User-Agent' => 'TestAgent',
|
||||
'Accept' => 'application/json',
|
||||
@@ -88,5 +88,3 @@ it('accepts valid event data and forwards headers', function () {
|
||||
&& isset($request['d']) && $request['d'] === 'example.com';
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user