mirror of
https://github.com/AzuraCast/AzuraCast.git
synced 2024-06-14 13:16:37 +00:00
45 lines
1.0 KiB
PHP
45 lines
1.0 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Nginx;
|
|
|
|
use App\Entity\Station;
|
|
|
|
final class CustomUrls
|
|
{
|
|
public static function getListenUrl(Station $station): string
|
|
{
|
|
return '/listen/' . $station->getShortName();
|
|
}
|
|
|
|
public static function getWebDjUrl(Station $station): string
|
|
{
|
|
return '/webdj/' . $station->getShortName();
|
|
}
|
|
|
|
public static function getHlsUrl(Station $station): string
|
|
{
|
|
return '/hls/' . $station->getShortName();
|
|
}
|
|
|
|
/**
|
|
* Returns a custom path if X-Accel-Redirect is configured for the path provided.
|
|
*/
|
|
public static function getXAccelPath(string $path): ?string
|
|
{
|
|
$specialPaths = [
|
|
'/var/azuracast/backups' => '/internal/backups',
|
|
'/var/azuracast/stations' => '/internal/stations',
|
|
];
|
|
|
|
foreach ($specialPaths as $diskPath => $nginxPath) {
|
|
if (str_starts_with($path, $diskPath)) {
|
|
return str_replace($diskPath, $nginxPath, $path);
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|