| 123456789101112131415161718192021222324252627 |
- <?php
- Lib::loadClass('HttpException');
- class Router {
- public static function route($route) {
- if (empty($route)) return;
- $routeClassName = "Route_{$route}";
- if (Lib::tryLoadClass($routeClassName)) {
- $route = new $routeClassName();
- try {
- $route->route();
- } catch (HttpException $e) {
- Http::sendHeaderByCode($e->getCode());
- die($e->getMessage());
- } catch (Exception $e) {
- die($e->getMessage());
- }
- exit;
- } else {
- die("Route '{$route}' not exists");
- }
- }
- }
|