31 lines
707 B
PHP
31 lines
707 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
class AssetController
|
|
{
|
|
private const ALLOWED = [
|
|
'app.css' => 'text/css',
|
|
'app.js' => 'application/javascript',
|
|
];
|
|
|
|
public function serve(): void
|
|
{
|
|
$f3 = Base::instance();
|
|
$file = basename((string) $f3->get('PARAMS.file'));
|
|
|
|
if (!array_key_exists($file, self::ALLOWED)) {
|
|
$f3->error(404);
|
|
return;
|
|
}
|
|
|
|
$f3->expire(86400);
|
|
echo Web::instance()->minify(
|
|
$file,
|
|
self::ALLOWED[$file],
|
|
true, // envoie le Content-Type
|
|
app_root() . '/public/assets/' // répertoire source (hors UI)
|
|
);
|
|
}
|
|
}
|