Esempio n. 1
0
 public function index(Request $request)
 {
     $response = new Response();
     $content = view('news.list', ['page' => 'news']);
     $response->content($content);
     return $response;
 }
 public function index()
 {
     $response = new Response();
     $content = view('index.index', ['content' => "Главная страница"]);
     $response->content($content);
     return $response;
 }
Esempio n. 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;
 }
Esempio n. 4
0
 public function response(Response $response)
 {
     $headers = $response->headers();
     ob_clean();
     foreach ($headers as $header => $value) {
         header("{$header}: {$value}");
     }
     echo $response->content();
     exit;
 }
Esempio n. 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();
 }