28 lines
671 B
PHP
28 lines
671 B
PHP
<?php
|
|
|
|
namespace App\Core;
|
|
|
|
final class Response
|
|
{
|
|
public static function redirect(string $url): never
|
|
{
|
|
if (str_starts_with($url, '/') && function_exists('url')) {
|
|
$url = \url($url);
|
|
} else {
|
|
$prefix = $_SERVER['KAFFEEKASSE_PROXY_PREFIX'] ?? '';
|
|
if ($prefix !== '' && str_starts_with($url, '/') && !str_starts_with($url, $prefix)) {
|
|
$url = $prefix . $url;
|
|
}
|
|
}
|
|
|
|
header('Location: ' . $url);
|
|
exit;
|
|
}
|
|
|
|
public static function notFound(string $message = 'Seite nicht gefunden.'): void
|
|
{
|
|
http_response_code(404);
|
|
echo $message;
|
|
}
|
|
}
|