mapguesser/public/index.php

28 lines
649 B
PHP
Raw Normal View History

<?php
require '../main.php';
// very basic routing
2020-05-20 13:06:40 +02:00
$host = $_SERVER["REQUEST_SCHEME"] . '://' . $_SERVER["SERVER_NAME"];
$url = $_SERVER['REQUEST_URI'];
switch($url) {
case '/game':
$controller = new MapGuesser\Controller\GameController();
break;
case '/getNewPosition.json':
$controller = new MapGuesser\Controller\GetNewPosition();
break;
2020-05-20 13:06:40 +02:00
case '/':
header('Location: ' . $host . '/game', true, 302);
die;
default:
echo 'Error 404';
die;
}
$view = $controller->run();
header('Content-Type: ' . $view->getContentType() . '; charset=UTF-8');
echo $view->render();