public function find() { $route = $this->getRouter()->getCurrentRoute(); $file = $route->getParameter('file'); $ext = $route->getParameter('ext'); if ($file = ModulesFileSystem::findFile('resources', $file, $ext)) { return (new Response(file_get_contents($file)))->header('Content-Type', Mime::byExt($ext))->header('last-modified', date('r', filemtime($file))); } abort(404); }
/** * @param string $message * @param int $code * @param Exception|null $previous */ public function __construct($message = '', $code = 0, Exception $previous = null) { parent::__construct($message, $code, $previous); if (config('app.debug')) { return; } $ext = pathinfo(Request::getUri(), PATHINFO_EXTENSION); $mimeType = null; if (empty($ext) or $ext and !($mimeType = Mime::byExt($ext))) { $mimeType = 'text/html'; } if ($mimeType and $mimeType != 'text/html') { $response = new Response(); $this->sendResponse($response, $mimeType); } elseif (!is_null($page = FrontendPage::findByField('behavior', 'page.not.found'))) { /** @var FrontendController $controller */ $controller = app()->make(FrontendController::class); $response = app()->call([$controller, 'run'], [$page->getUri()]); $this->sendResponse($response, $mimeType); } }