23 lines
801 B
PHP
23 lines
801 B
PHP
<?php
|
|
|
|
namespace IriksIT\Manager\Http\Controllers;
|
|
|
|
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
|
|
|
/** The built screens, served by the package itself: the app does not need Node, a build step or a publish. */
|
|
class AssetController
|
|
{
|
|
private const FILES = ['manager.js' => 'application/javascript', 'manager.css' => 'text/css', 'vue.js' => 'application/javascript'];
|
|
|
|
public function __invoke(string $file): BinaryFileResponse
|
|
{
|
|
abort_unless(isset(self::FILES[$file]) && is_file($path = __DIR__.'/../../../resources/dist/'.$file), 404);
|
|
|
|
return response()->file($path, [
|
|
'Content-Type' => self::FILES[$file],
|
|
'Cache-Control' => 'public, max-age=31536000, immutable',
|
|
'X-Content-Type-Options' => 'nosniff',
|
|
]);
|
|
}
|
|
}
|