Skip to content

Commit 3217a0b

Browse files
author
Florian Engelhardt
committed
add json pretty print and cleanup of array notation
1 parent 24a4369 commit 3217a0b

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

api/app.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@
3232
$output = $result->toArray();
3333
return new Response(
3434
200,
35-
array(
35+
[
3636
'Content-Type' => 'application/json'
37-
),
38-
json_encode($output)
37+
],
38+
json_encode($output, JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR)
3939
);
4040
});
4141
});

products/app.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@
1212
$server = new Server(function (ServerRequestInterface $request) {
1313
return new Response(
1414
200,
15-
array(
15+
[
1616
'Content-Type' => 'application/json'
17-
),
17+
],
1818
json_encode([
1919
'id' => 1,
2020
'name' => 'Avengers',
2121
'description' => 'a movie'
22-
])
22+
], JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR)
2323
);
2424
});
2525
$socket = new \React\Socket\Server('0.0.0.0:3000', $loop);

reviews/app.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@
1212
$server = new Server(function (ServerRequestInterface $request) {
1313
return new Response(
1414
200,
15-
array(
15+
[
1616
'Content-Type' => 'application/json'
17-
),
17+
],
1818
json_encode([
1919
'id' => 2,
2020
'title' => 'Oh snap what an ending',
2121
'grade' => 5,
2222
'comment' => 'I need therapy after this...',
2323
'product' => 1
24-
])
24+
], JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR)
2525
);
2626
});
2727
$socket = new \React\Socket\Server('0.0.0.0:3000', $loop);

0 commit comments

Comments
 (0)