juggl/juggl-server/api/services/responses.inc.php
2020-11-08 15:21:51 +01:00

25 lines
No EOL
528 B
PHP

<?php
require_once(__DIR__."/jsonBuilder.inc.php");
function respondJson(JsonBuilder $builder) {
header('Content-type: application/json');
echo($builder->getJson());
}
function respondHtml(string $html) {
print($html);
}
function respondStatus(int $statusCode, string $message = "") {
http_response_code($statusCode);
die($message);
}
function redirectBack() {
header("Location: {$_SERVER['HTTP_REFERER']}");
}
function redirectTo($url) {
header("Location: {$url}");
}
?>