public function sendResponse($data) { switch ($this->contentType) { case 'text/html': Response::html($data); break; case 'application/json': case 'text/json': header('Content-type:text/json'); Response::json($data); break; } }
<?php Event::on(404, function () { Response::html(View::from('special/error', ['code' => 404, 'message' => 'Page not found'])); }); Route::on('/', function () { return View::from('index'); });