Skip to content

Commit

Permalink
Add encode function
Browse files Browse the repository at this point in the history
  • Loading branch information
joanhey committed Feb 25, 2024
1 parent 822cede commit 99397bf
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion tests/Servers/Workerman.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,20 @@

Worker::runAll();

function encode(mixed $data): Response
{
//so we can change it later
return new Response(
200,
['Content-Type' => 'application/json'],
json_encode($data, JSON_PRETTY_PRINT)
);
}

function cookies(Request $request): string
{
if ($request->get() === []) {
return encode($request->cookie() ?? []);
return encode($request->cookie());
}

$response = new Response(headers: ['Content-Type' => 'application/json']);
Expand Down

0 comments on commit 99397bf

Please sign in to comment.