willy.club/routes/start.php

33 lines
847 B
PHP
Raw Normal View History

2022-11-29 12:49:29 +00:00
<?php
use WillySoft\Http\ErrorHandler;
use WillySoft\Http\Route;
2023-01-29 12:35:00 +00:00
// enable debug here so we display config parse errors to the user
$debug = true;
ErrorHandler::register(function($error_messages) use (&$debug) {
if ($debug) {
view('errors/500', ['error_messages' => $error_messages]);
} else {
view('errors/500', ['error_messages' => []]);
}
2022-11-29 12:49:29 +00:00
});
2023-01-29 12:35:00 +00:00
// if config loads successfully use that value instead
$debug = config('debug');
unset($debug);
2022-11-29 12:49:29 +00:00
Route::get('/', fn() => view('pages/home'));
2023-01-07 17:49:47 +00:00
2023-01-22 09:47:36 +00:00
Route::group(function() {
require __DIR__ . '/willychat.php';
});
2023-01-02 14:38:51 +00:00
Route::get('/test/$whatever?', function($whatever = 'Default Value') {
echo htmlspecialchars($whatever);
});
2023-01-07 17:49:47 +00:00
2023-01-02 14:38:51 +00:00
Route::get('/error', fn() => 1 / 0);
2022-11-29 12:49:29 +00:00
// since no route was matched we show a page not found error
http_response_code(404);
2023-01-20 19:33:45 +00:00
view('errors/404');