예제 #1
0
 public function index(Request $request)
 {
     $response = new Response();
     $content = view('news.list', ['page' => 'news']);
     $response->content($content);
     return $response;
 }
예제 #2
0
 public function index()
 {
     $response = new Response();
     $content = view('index.index', ['content' => "Главная страница"]);
     $response->content($content);
     return $response;
 }
예제 #3
0
 public function index(Request $request)
 {
     $newsModel = new Models\NewsModel();
     $onPage = 10;
     $page = intval($request->get('page'));
     $news = $newsModel->select($page, $onPage);
     $response = new Response();
     $response->header('Content-type', 'application/json')->content(json_encode(['method' => 'newslist', 'result' => ['items' => $news, 'total' => 12, 'page' => $page, 'onpage' => $onPage, 'pages' => 2]]));
     return $response;
 }
예제 #4
0
 public function response(Response $response)
 {
     $headers = $response->headers();
     ob_clean();
     foreach ($headers as $header => $value) {
         header("{$header}: {$value}");
     }
     echo $response->content();
     exit;
 }
예제 #5
0
 /**
  * 输出HTTP异常信息
  *
  * @param HttpException $e
  */
 protected function renderHttpException(HttpException $e)
 {
     $message = $e->getMessage();
     if (empty($message)) {
         $message = Response::getStatusText($e->getCode());
     }
     $response = new Response();
     $response->setStatus($e->getCode());
     $response->setContent("<h1>{$message}</h1>");
     $response->send();
 }