function onRequest(Swoole\Request $request)
{
$response = new Swoole\Response();
$php = Swoole::getInstance();
$request->setGlobal();
// if($this->doStaticRequest($request, $response))
// {
// return $response;
// }
//将对象赋值到控制器
$php->request = $request;
$php->response = $response;
$response->head['Cache-Control'] = 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0';
$response->head['Pragma'] = 'no-cache';
try {
ob_start();
/*---------------------处理MVC----------------------*/
$response->body = $php->runMVC();
$response->body .= ob_get_contents();
ob_end_clean();
} catch (\Exception $e) {
if ($request->finish != 1) {
$this->http_error(404, $response, $e->getMessage());
}
}
if (!isset($response->head['Content-Type'])) {
$response->head['Content-Type'] = 'text/html; charset=' . $this->config['apps']['charset'];
}
//重定向
if (isset($response->head['Location'])) {
$response->send_http_status(301);
}
return $response;
}