<?php /** * Created by PhpStorm * Author:FireRabbit * Date:2021/2/15 * Time:16:26 **/
namespace FireRabbitEngine\Module\Http;
use FireRabbitEngine\Module\Constant; use FireRabbitEngine\Module\Database\Manager as DatabaseManager; use FireRabbitEngine\Module\Logger\Log as Logger; use FireRabbitEngine\Module\Route\Router; use FireRabbitEngine\Module\View\Blade; use Swoole\Http\Server;
class HttpServer { public $server; public $router;
public function __construct($host, $port, $config = []) { $this->server = new Server($host, $port); $this->server->set($config); }
public function loadRouter(Router $router) { $this->router = $router; return $this; }
public function loadMiddleware($middleware) { \FireRabbitEngine\Module\Http\Middleware\Kernel::setConfig($middleware); return $this; }
public function bootstrap($config) { Blade::setConfig($config[Constant::VIEW_CONFIG]); DatabaseManager::setConfig($config[Constant::DATABASE_CONFIG]); Logger::setConfig($config[Constant::LOGGER_CONFIG]);
return $this; }
public function request($request, $response) { var_dump('请求URI:' . $request->server['request_uri']);