|
@@ -13,7 +13,7 @@ $http_worker->onWorkerStart = function () {
|
|
$pdo = new PDO('mysql:host=tfb-database;dbname=hello_world;charset=utf8',
|
|
$pdo = new PDO('mysql:host=tfb-database;dbname=hello_world;charset=utf8',
|
|
'benchmarkdbuser', 'benchmarkdbpass');
|
|
'benchmarkdbuser', 'benchmarkdbpass');
|
|
};
|
|
};
|
|
-$http_worker->onMessage = function ($connection) {
|
|
|
|
|
|
+$http_worker->onMessage = static function ($connection) {
|
|
global $pdo;
|
|
global $pdo;
|
|
|
|
|
|
Http::header('Date: '.gmdate('D, d M Y H:i:s').' GMT');
|
|
Http::header('Date: '.gmdate('D, d M Y H:i:s').' GMT');
|
|
@@ -21,28 +21,23 @@ $http_worker->onMessage = function ($connection) {
|
|
switch (parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)) {
|
|
switch (parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)) {
|
|
case '/plaintext':
|
|
case '/plaintext':
|
|
Http::header('Content-Type: text/plain');
|
|
Http::header('Content-Type: text/plain');
|
|
- $connection->send('Hello, World!');
|
|
|
|
- break;
|
|
|
|
|
|
+ return $connection->send('Hello, World!');
|
|
|
|
|
|
case '/json':
|
|
case '/json':
|
|
Http::header('Content-Type: application/json');
|
|
Http::header('Content-Type: application/json');
|
|
- $connection->send(json_encode(['message' => 'Hello, World!']));
|
|
|
|
- break;
|
|
|
|
|
|
+ return $connection->send(json_encode(['message' => 'Hello, World!']));
|
|
|
|
|
|
case '/db':
|
|
case '/db':
|
|
Http::header('Content-Type: application/json');
|
|
Http::header('Content-Type: application/json');
|
|
- $connection->send(dbraw($pdo));
|
|
|
|
- break;
|
|
|
|
|
|
+ return $connection->send(dbraw($pdo));
|
|
|
|
|
|
case '/fortune':
|
|
case '/fortune':
|
|
Http::header('Content-Type: text/html; charset=utf-8');
|
|
Http::header('Content-Type: text/html; charset=utf-8');
|
|
- $connection->send(fortune($pdo));
|
|
|
|
- break;
|
|
|
|
|
|
+ return $connection->send(fortune($pdo));
|
|
|
|
|
|
case '/update':
|
|
case '/update':
|
|
Http::header('Content-Type: application/json');
|
|
Http::header('Content-Type: application/json');
|
|
- $connection->send(updateraw($pdo));
|
|
|
|
- break;
|
|
|
|
|
|
+ return $connection->send(updateraw($pdo));
|
|
|
|
|
|
//case '/info':
|
|
//case '/info':
|
|
// Http::header('Content-Type: text/plain');
|
|
// Http::header('Content-Type: text/plain');
|