Skip to content

Commit f7fb645

Browse files
author
Florian Engelhardt
committed
add simple reviews endpoint with app, composer deps and dockerfile
1 parent cf76533 commit f7fb645

File tree

4 files changed

+633
-0
lines changed

4 files changed

+633
-0
lines changed

reviews/Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM php:7.3-alpine
2+
WORKDIR /app
3+
ENV PORT=3000
4+
COPY . .
5+
EXPOSE $PORT
6+
ENTRYPOINT ["php", "app.php"]

reviews/app.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
use Psr\Http\Message\ServerRequestInterface;
5+
use React\EventLoop\Factory;
6+
use React\Http\Response;
7+
use React\Http\Server;
8+
9+
require __DIR__ . '/vendor/autoload.php';
10+
11+
$loop = Factory::create();
12+
$server = new Server(function (ServerRequestInterface $request) {
13+
return new Response(
14+
200,
15+
array(
16+
'Content-Type' => 'application/json'
17+
),
18+
json_encode([
19+
'id' => 2,
20+
'title' => 'Oh snap what an ending',
21+
'grade' => 5,
22+
'comment' => 'I need therapy after this...',
23+
'product' => 1
24+
])
25+
);
26+
});
27+
$socket = new \React\Socket\Server('0.0.0.0:3000', $loop);
28+
$server->listen($socket);
29+
echo 'Listening on ' . str_replace('tcp:', 'http:', $socket->getAddress()) . PHP_EOL;
30+
$loop->run();

reviews/composer.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"require": {
3+
"react/http": "^0.8.4"
4+
}
5+
}

0 commit comments

Comments
 (0)