<?php
Swoole\HTTP\Server->on('request', callback $callback)
The event name
callback function
if success, it returns TRUE, otherwise it returns FALSE.
Executue the callback function when receiving HTTP request.
<?php
$http = new Swoole\HTTP\Server("127.0.0.1", 9501);
$http->on('request', function ($request, $response) {
$response->end("<h1>Hello World. #".rand(1000, 9999)."</h1>");
});
$http->start();