DK2/public/index.php

45 lines
951 B
PHP
Raw Normal View History

2024-09-27 18:45:33 -05:00
<?php
/*
Setup
*/
2024-09-27 18:45:33 -05:00
define('SRC', __DIR__ . '/../src');
require_once SRC . '/bootstrap.php';
$r = [];
/*
Home
*/
2024-09-27 18:45:33 -05:00
router_get($r, '/', function () {
echo render('layouts/basic', ['view' => 'pages/home']);
});
/*
Auth
*/
router_get($r, '/auth/register', 'auth_controller_register_get');
router_post($r, '/auth/register', 'auth_controller_register_post');
router_get($r, '/auth/login', 'auth_controller_login_get');
router_post($r, '/auth/login', 'auth_controller_login_post');
router_post($r, '/auth/logout', 'auth_controller_logout_post');
2024-09-27 18:45:33 -05:00
/*
Characters
*/
router_post($r, '/character/create', 'char_controller_create_post');
router_post($r, '/character/select', 'auth_controller_change_character_post');
/*
Router
*/
2024-09-27 18:45:33 -05:00
// [code, handler, params]
$l = router_lookup($r, $_SERVER['REQUEST_METHOD'], $_SERVER['REQUEST_URI']);
if ($l['code'] !== 200) router_error($l['code']);
$l['handler'](...$l['params'] ?? []);
/*
Cleanup
*/
2024-09-27 18:45:33 -05:00
clear_flashes();