From 2f41a1e988d4a6668e09701275a527e4e725acac Mon Sep 17 00:00:00 2001 From: Yarmo Mackenbach Date: Fri, 26 Jun 2020 17:00:22 +0200 Subject: [PATCH] Add PHP router --- index.php | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 index.php diff --git a/index.php b/index.php new file mode 100644 index 0000000..ab9ffec --- /dev/null +++ b/index.php @@ -0,0 +1,44 @@ +map('GET', '/', function() {}, 'index'); +$router->map('GET', '/verify', function() {}, 'verify'); +$router->map('GET', '/encrypt', function() {}, 'encrypt'); +$router->map('GET', '/proofs', function() {}, 'proofs'); +$router->map('GET', '/faq', function() {}, 'faq'); + +// Router matching +$match = $router->match(); + +// Render the appropriate route +if(is_array($match) && is_callable($match['target'])) { + switch ($match['name']) { + case 'index': + readfile('pages/index.html'); + break; + + case 'verify': + readfile('pages/verify.html'); + break; + + case 'encrypt': + readfile('pages/encrypt.html'); + break; + + case 'proofs': + readfile('pages/proofs.html'); + break; + + case 'faq': + readfile('pages/faq.html'); + break; + } +} else { + // No route was matched +}