public function runHttpServer(callable $callback) { $this->dispatcher = new Dispatcher(); $this->routes = Config::get('routes', []); $loop = Factory::create(); $socket = new Socket($loop); $http = new Http($socket); $http->on(REQUEST, $callback); Memory::create(HTTP); $socket->listen(Memory::get(HTTP)->get(PORT, '1337'), Memory::get(HTTP)->get(HOST, '127.0.0.1')); Memory::events()->on(STOP, function () { Memory::get(HTTP)->set(CODE, 200); Memory::get(HTTP)->set(HEADER, DEFAULT_HEADERS); }); $loop->run(); }