From 9741345a086fef4d82b0636e87e0383ccf0964d6 Mon Sep 17 00:00:00 2001 From: flashwave Date: Sat, 30 Mar 2024 01:16:42 +0000 Subject: [PATCH] new router event --- composer.lock | 156 ++++++++++++++----------------- src/AssetsRoutes.php | 5 +- src/DeveloperRoutes.php | 13 ++- src/MakaiContext.php | 3 +- src/RoutingContext.php | 25 ++--- src/RoutingErrorHandler.php | 17 ++++ src/SSHKeys/SSHKeysRoutes.php | 13 ++- src/Tools/AsciiRoutes.php | 7 +- src/Tools/RandomStringRoutes.php | 7 +- src/Whois/WhoisRoutes.php | 7 +- 10 files changed, 116 insertions(+), 137 deletions(-) create mode 100644 src/RoutingErrorHandler.php diff --git a/composer.lock b/composer.lock index b3c5b85..236b3ae 100644 --- a/composer.lock +++ b/composer.lock @@ -62,7 +62,7 @@ "source": { "type": "git", "url": "https://patchii.net/flash/index.git", - "reference": "e31781c69f0b13fe251771c8e7e529222630a44f" + "reference": "9d5b050b8928435416a7efbebe2a19ae8e626224" }, "require": { "ext-mbstring": "*", @@ -100,7 +100,7 @@ ], "description": "Composer package for the common library for my projects.", "homepage": "https://railgun.sh/index", - "time": "2023-11-20T19:01:19+00:00" + "time": "2024-03-28T23:27:04+00:00" }, { "name": "flashwave/sasae", @@ -108,7 +108,7 @@ "source": { "type": "git", "url": "https://patchii.net/flash/sasae.git", - "reference": "b56dd222acb8f138729e6258d4a90bbb8401ff52" + "reference": "c8a9f2974e6591215b3f898dd5525de1e8367f66" }, "require": { "flashwave/index": "dev-master", @@ -141,7 +141,7 @@ ], "description": "A wrapper for Twig with added common functionality.", "homepage": "https://railgun.sh/sasae", - "time": "2023-11-20T19:09:35+00:00" + "time": "2024-01-04T02:13:42+00:00" }, { "name": "flashwave/syokuhou", @@ -149,7 +149,7 @@ "source": { "type": "git", "url": "https://patchii.net/flash/syokuhou.git", - "reference": "fdf3c38cc216bf7024af331cbe1758532355c22f" + "reference": "c1fe9371ada20fcea51c225cc53b9ceae4642bc4" }, "require": { "flashwave/index": "dev-master", @@ -180,7 +180,7 @@ ], "description": "Configuration library for PHP.", "homepage": "https://railgun.sh/syokuhou", - "time": "2023-11-20T19:10:04+00:00" + "time": "2024-01-04T02:12:49+00:00" }, { "name": "guzzlehttp/psr7", @@ -300,16 +300,16 @@ }, { "name": "jean85/pretty-package-versions", - "version": "2.0.5", + "version": "2.0.6", "source": { "type": "git", "url": "https://github.com/Jean85/pretty-package-versions.git", - "reference": "ae547e455a3d8babd07b96966b17d7fd21d9c6af" + "reference": "f9fdd29ad8e6d024f52678b570e5593759b550b4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Jean85/pretty-package-versions/zipball/ae547e455a3d8babd07b96966b17d7fd21d9c6af", - "reference": "ae547e455a3d8babd07b96966b17d7fd21d9c6af", + "url": "https://api.github.com/repos/Jean85/pretty-package-versions/zipball/f9fdd29ad8e6d024f52678b570e5593759b550b4", + "reference": "f9fdd29ad8e6d024f52678b570e5593759b550b4", "shasum": "" }, "require": { @@ -317,9 +317,9 @@ "php": "^7.1|^8.0" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^2.17", + "friendsofphp/php-cs-fixer": "^3.2", "jean85/composer-provided-replaced-stub-package": "^1.0", - "phpstan/phpstan": "^0.12.66", + "phpstan/phpstan": "^1.4", "phpunit/phpunit": "^7.5|^8.5|^9.4", "vimeo/psalm": "^4.3" }, @@ -353,9 +353,9 @@ ], "support": { "issues": "https://github.com/Jean85/pretty-package-versions/issues", - "source": "https://github.com/Jean85/pretty-package-versions/tree/2.0.5" + "source": "https://github.com/Jean85/pretty-package-versions/tree/2.0.6" }, - "time": "2021-10-08T21:21:46+00:00" + "time": "2024-03-08T09:58:59+00:00" }, { "name": "psr/http-factory", @@ -616,16 +616,16 @@ }, { "name": "sentry/sentry", - "version": "4.1.0", + "version": "4.6.1", "source": { "type": "git", "url": "https://github.com/getsentry/sentry-php.git", - "reference": "89666f297891ff937fceb2f3d1fb967a6848cf37" + "reference": "5a94184175e5830b589bf923da8c9c3af2c0f409" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/getsentry/sentry-php/zipball/89666f297891ff937fceb2f3d1fb967a6848cf37", - "reference": "89666f297891ff937fceb2f3d1fb967a6848cf37", + "url": "https://api.github.com/repos/getsentry/sentry-php/zipball/5a94184175e5830b589bf923da8c9c3af2c0f409", + "reference": "5a94184175e5830b589bf923da8c9c3af2c0f409", "shasum": "" }, "require": { @@ -649,7 +649,7 @@ "phpbench/phpbench": "^1.0", "phpstan/phpstan": "^1.3", "phpunit/phpunit": "^8.5.14|^9.4", - "symfony/phpunit-bridge": "^5.2|^6.0", + "symfony/phpunit-bridge": "^5.2|^6.0|^7.0", "vimeo/psalm": "^4.17" }, "suggest": { @@ -689,7 +689,7 @@ ], "support": { "issues": "https://github.com/getsentry/sentry-php/issues", - "source": "https://github.com/getsentry/sentry-php/tree/4.1.0" + "source": "https://github.com/getsentry/sentry-php/tree/4.6.1" }, "funding": [ { @@ -701,7 +701,7 @@ "type": "custom" } ], - "time": "2023-12-04T12:41:21+00:00" + "time": "2024-03-08T08:18:09+00:00" }, { "name": "symfony/deprecation-contracts", @@ -772,16 +772,16 @@ }, { "name": "symfony/mime", - "version": "v7.0.0", + "version": "v7.0.3", "source": { "type": "git", "url": "https://github.com/symfony/mime.git", - "reference": "0a2fff95c1a10df97f571d67e76c7ae0f0d4f535" + "reference": "c1ffe24ba6fdc3e3f0f3fcb93519103b326a3716" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/mime/zipball/0a2fff95c1a10df97f571d67e76c7ae0f0d4f535", - "reference": "0a2fff95c1a10df97f571d67e76c7ae0f0d4f535", + "url": "https://api.github.com/repos/symfony/mime/zipball/c1ffe24ba6fdc3e3f0f3fcb93519103b326a3716", + "reference": "c1ffe24ba6fdc3e3f0f3fcb93519103b326a3716", "shasum": "" }, "require": { @@ -835,7 +835,7 @@ "mime-type" ], "support": { - "source": "https://github.com/symfony/mime/tree/v7.0.0" + "source": "https://github.com/symfony/mime/tree/v7.0.3" }, "funding": [ { @@ -851,7 +851,7 @@ "type": "tidelift" } ], - "time": "2023-10-19T14:20:43+00:00" + "time": "2024-01-30T08:34:29+00:00" }, { "name": "symfony/options-resolver", @@ -922,16 +922,16 @@ }, { "name": "symfony/polyfill-ctype", - "version": "v1.28.0", + "version": "v1.29.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "ea208ce43cbb04af6867b4fdddb1bdbf84cc28cb" + "reference": "ef4d7e442ca910c4764bce785146269b30cb5fc4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/ea208ce43cbb04af6867b4fdddb1bdbf84cc28cb", - "reference": "ea208ce43cbb04af6867b4fdddb1bdbf84cc28cb", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/ef4d7e442ca910c4764bce785146269b30cb5fc4", + "reference": "ef4d7e442ca910c4764bce785146269b30cb5fc4", "shasum": "" }, "require": { @@ -945,9 +945,6 @@ }, "type": "library", "extra": { - "branch-alias": { - "dev-main": "1.28-dev" - }, "thanks": { "name": "symfony/polyfill", "url": "https://github.com/symfony/polyfill" @@ -984,7 +981,7 @@ "portable" ], "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.28.0" + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.29.0" }, "funding": [ { @@ -1000,20 +997,20 @@ "type": "tidelift" } ], - "time": "2023-01-26T09:26:14+00:00" + "time": "2024-01-29T20:11:03+00:00" }, { "name": "symfony/polyfill-intl-idn", - "version": "v1.28.0", + "version": "v1.29.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-idn.git", - "reference": "ecaafce9f77234a6a449d29e49267ba10499116d" + "reference": "a287ed7475f85bf6f61890146edbc932c0fff919" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/ecaafce9f77234a6a449d29e49267ba10499116d", - "reference": "ecaafce9f77234a6a449d29e49267ba10499116d", + "url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/a287ed7475f85bf6f61890146edbc932c0fff919", + "reference": "a287ed7475f85bf6f61890146edbc932c0fff919", "shasum": "" }, "require": { @@ -1026,9 +1023,6 @@ }, "type": "library", "extra": { - "branch-alias": { - "dev-main": "1.28-dev" - }, "thanks": { "name": "symfony/polyfill", "url": "https://github.com/symfony/polyfill" @@ -1071,7 +1065,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-idn/tree/v1.28.0" + "source": "https://github.com/symfony/polyfill-intl-idn/tree/v1.29.0" }, "funding": [ { @@ -1087,20 +1081,20 @@ "type": "tidelift" } ], - "time": "2023-01-26T09:30:37+00:00" + "time": "2024-01-29T20:11:03+00:00" }, { "name": "symfony/polyfill-intl-normalizer", - "version": "v1.28.0", + "version": "v1.29.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-normalizer.git", - "reference": "8c4ad05dd0120b6a53c1ca374dca2ad0a1c4ed92" + "reference": "bc45c394692b948b4d383a08d7753968bed9a83d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/8c4ad05dd0120b6a53c1ca374dca2ad0a1c4ed92", - "reference": "8c4ad05dd0120b6a53c1ca374dca2ad0a1c4ed92", + "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/bc45c394692b948b4d383a08d7753968bed9a83d", + "reference": "bc45c394692b948b4d383a08d7753968bed9a83d", "shasum": "" }, "require": { @@ -1111,9 +1105,6 @@ }, "type": "library", "extra": { - "branch-alias": { - "dev-main": "1.28-dev" - }, "thanks": { "name": "symfony/polyfill", "url": "https://github.com/symfony/polyfill" @@ -1155,7 +1146,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.28.0" + "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.29.0" }, "funding": [ { @@ -1171,20 +1162,20 @@ "type": "tidelift" } ], - "time": "2023-01-26T09:26:14+00:00" + "time": "2024-01-29T20:11:03+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.28.0", + "version": "v1.29.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "42292d99c55abe617799667f454222c54c60e229" + "reference": "9773676c8a1bb1f8d4340a62efe641cf76eda7ec" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/42292d99c55abe617799667f454222c54c60e229", - "reference": "42292d99c55abe617799667f454222c54c60e229", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/9773676c8a1bb1f8d4340a62efe641cf76eda7ec", + "reference": "9773676c8a1bb1f8d4340a62efe641cf76eda7ec", "shasum": "" }, "require": { @@ -1198,9 +1189,6 @@ }, "type": "library", "extra": { - "branch-alias": { - "dev-main": "1.28-dev" - }, "thanks": { "name": "symfony/polyfill", "url": "https://github.com/symfony/polyfill" @@ -1238,7 +1226,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.28.0" + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.29.0" }, "funding": [ { @@ -1254,20 +1242,20 @@ "type": "tidelift" } ], - "time": "2023-07-28T09:04:16+00:00" + "time": "2024-01-29T20:11:03+00:00" }, { "name": "symfony/polyfill-php72", - "version": "v1.28.0", + "version": "v1.29.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php72.git", - "reference": "70f4aebd92afca2f865444d30a4d2151c13c3179" + "reference": "861391a8da9a04cbad2d232ddd9e4893220d6e25" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/70f4aebd92afca2f865444d30a4d2151c13c3179", - "reference": "70f4aebd92afca2f865444d30a4d2151c13c3179", + "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/861391a8da9a04cbad2d232ddd9e4893220d6e25", + "reference": "861391a8da9a04cbad2d232ddd9e4893220d6e25", "shasum": "" }, "require": { @@ -1275,9 +1263,6 @@ }, "type": "library", "extra": { - "branch-alias": { - "dev-main": "1.28-dev" - }, "thanks": { "name": "symfony/polyfill", "url": "https://github.com/symfony/polyfill" @@ -1314,7 +1299,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php72/tree/v1.28.0" + "source": "https://github.com/symfony/polyfill-php72/tree/v1.29.0" }, "funding": [ { @@ -1330,20 +1315,20 @@ "type": "tidelift" } ], - "time": "2023-01-26T09:26:14+00:00" + "time": "2024-01-29T20:11:03+00:00" }, { "name": "symfony/polyfill-php80", - "version": "v1.28.0", + "version": "v1.29.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "6caa57379c4aec19c0a12a38b59b26487dcfe4b5" + "reference": "87b68208d5c1188808dd7839ee1e6c8ec3b02f1b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/6caa57379c4aec19c0a12a38b59b26487dcfe4b5", - "reference": "6caa57379c4aec19c0a12a38b59b26487dcfe4b5", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/87b68208d5c1188808dd7839ee1e6c8ec3b02f1b", + "reference": "87b68208d5c1188808dd7839ee1e6c8ec3b02f1b", "shasum": "" }, "require": { @@ -1351,9 +1336,6 @@ }, "type": "library", "extra": { - "branch-alias": { - "dev-main": "1.28-dev" - }, "thanks": { "name": "symfony/polyfill", "url": "https://github.com/symfony/polyfill" @@ -1397,7 +1379,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.28.0" + "source": "https://github.com/symfony/polyfill-php80/tree/v1.29.0" }, "funding": [ { @@ -1413,7 +1395,7 @@ "type": "tidelift" } ], - "time": "2023-01-26T09:26:14+00:00" + "time": "2024-01-29T20:11:03+00:00" }, { "name": "twig/html-extra", @@ -1555,16 +1537,16 @@ "packages-dev": [ { "name": "phpstan/phpstan", - "version": "1.10.50", + "version": "1.10.66", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "06a98513ac72c03e8366b5a0cb00750b487032e4" + "reference": "94779c987e4ebd620025d9e5fdd23323903950bd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/06a98513ac72c03e8366b5a0cb00750b487032e4", - "reference": "06a98513ac72c03e8366b5a0cb00750b487032e4", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/94779c987e4ebd620025d9e5fdd23323903950bd", + "reference": "94779c987e4ebd620025d9e5fdd23323903950bd", "shasum": "" }, "require": { @@ -1613,7 +1595,7 @@ "type": "tidelift" } ], - "time": "2023-12-13T10:59:42+00:00" + "time": "2024-03-28T16:17:31+00:00" } ], "aliases": [], @@ -1627,5 +1609,5 @@ "prefer-lowest": false, "platform": [], "platform-dev": [], - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.6.0" } diff --git a/src/AssetsRoutes.php b/src/AssetsRoutes.php index 79eb773..8667183 100644 --- a/src/AssetsRoutes.php +++ b/src/AssetsRoutes.php @@ -1,15 +1,14 @@ siteInfo->getHeaderImages(); } diff --git a/src/DeveloperRoutes.php b/src/DeveloperRoutes.php index 9fb5bb4..a912e97 100644 --- a/src/DeveloperRoutes.php +++ b/src/DeveloperRoutes.php @@ -1,8 +1,7 @@ projects->getProjects( featuredOnly: true, @@ -41,19 +40,19 @@ class DeveloperRoutes extends RouteHandler { ]); } - #[Route('GET', '/home')] + #[HttpGet('/home')] public function getPersonalHome(): string { return $this->templating->render('dev/home'); } - #[Route('GET', '/contact')] + #[HttpGet('/contact')] public function getContact(): string { return $this->templating->render('dev/contact', [ 'contacts' => $this->contacts->getContacts(), ]); } - #[Route('GET', '/projects')] + #[HttpGet('/projects')] public function getProjects(): string { $projectInfos = $this->projects->getProjects(deleted: false); @@ -78,7 +77,7 @@ class DeveloperRoutes extends RouteHandler { ]); } - #[Route('GET', '/now-listening')] + #[HttpGet('/now-listening')] public function getNowListening($response, $request): string { return $this->templating->render('dev/np', [ 'header_offset' => (int)$request->getParam('offset', FILTER_SANITIZE_NUMBER_INT), diff --git a/src/MakaiContext.php b/src/MakaiContext.php index bf83e3d..2063154 100644 --- a/src/MakaiContext.php +++ b/src/MakaiContext.php @@ -89,8 +89,7 @@ final class MakaiContext { } public function createRouting(): RoutingContext { - $routingCtx = new RoutingContext($this->templating); - $routingCtx->registerDefaultErrorPages(); + $routingCtx = new RoutingContext; $routingCtx->register(new DeveloperRoutes($this->templating, $this->contacts, $this->projects)); $routingCtx->register(new AssetsRoutes($this->siteInfo)); diff --git a/src/RoutingContext.php b/src/RoutingContext.php index 29ae9f8..351e2cf 100644 --- a/src/RoutingContext.php +++ b/src/RoutingContext.php @@ -1,19 +1,14 @@ templating = $templating; - $this->router = new HttpFx; + public function __construct() { + $this->router = new HttpRouter(errorHandler: new RoutingErrorHandler); $this->router->use('/', fn($resp) => $resp->setPoweredBy('Makai')); } @@ -21,19 +16,11 @@ class RoutingContext { return $this->router; } - public function registerDefaultErrorPages(): void { - $this->router->addErrorHandler(401, fn($resp) => $resp->setContent(file_get_contents(MKI_DIR_PUBLIC . '/error-401.html'))); - $this->router->addErrorHandler(403, fn($resp) => $resp->setContent(file_get_contents(MKI_DIR_PUBLIC . '/error-403.html'))); - $this->router->addErrorHandler(404, fn($resp) => $resp->setContent(file_get_contents(MKI_DIR_PUBLIC . '/error-404.html'))); - $this->router->addErrorHandler(500, fn($resp) => $resp->setContent(file_get_contents(MKI_DIR_PUBLIC . '/error-500.html'))); - $this->router->addErrorHandler(503, fn($resp) => $resp->setContent(file_get_contents(MKI_DIR_PUBLIC . '/error-503.html'))); - } - public function register(IRouteHandler $handler): void { $this->router->register($handler); } - public function dispatch(?HttpRequest $request = null): void { - $this->router->dispatch($request); + public function dispatch(): void { + $this->router->dispatch(); } } diff --git a/src/RoutingErrorHandler.php b/src/RoutingErrorHandler.php new file mode 100644 index 0000000..985e570 --- /dev/null +++ b/src/RoutingErrorHandler.php @@ -0,0 +1,17 @@ +setTypeHTML(); + $response->accelRedirect(sprintf('/error-%s.html', $code)); + return; + } + + parent::handle($response, $request, $code, $message); + } +} diff --git a/src/SSHKeys/SSHKeysRoutes.php b/src/SSHKeys/SSHKeysRoutes.php index 1450ef3..06f2d92 100644 --- a/src/SSHKeys/SSHKeysRoutes.php +++ b/src/SSHKeys/SSHKeysRoutes.php @@ -1,15 +1,14 @@ getParam('l', FILTER_SANITIZE_NUMBER_INT); $includeComment = $request->hasParam('c'); @@ -43,7 +42,7 @@ class SSHKeysRoutes extends RouteHandler { return $body; } - #[Route('GET', '/authorized_keys')] + #[HttpGet('/authorized_keys')] public function getAuthorisedKeys($response, $request): string { $response->setTypePlain(); $body = ''; @@ -55,7 +54,7 @@ class SSHKeysRoutes extends RouteHandler { return $body; } - #[Route('GET', '/git_keys_ro')] + #[HttpGet('/git_keys_ro')] public function getGitKeysReadOnly($response, $request): string { $response->setTypePlain(); $body = ''; @@ -67,7 +66,7 @@ class SSHKeysRoutes extends RouteHandler { return $body; } - #[Route('GET', '/git_keys_rw')] + #[HttpGet('/git_keys_rw')] public function getGitKeysReadWrite($response, $request): string { $response->setTypePlain(); $body = ''; @@ -79,7 +78,7 @@ class SSHKeysRoutes extends RouteHandler { return $body; } - #[Route('GET', '/ssh.php')] + #[HttpGet('/ssh.php')] public function getSshPhp($response, $request): void { $query = []; diff --git a/src/Tools/AsciiRoutes.php b/src/Tools/AsciiRoutes.php index b9fd88f..293e9d9 100644 --- a/src/Tools/AsciiRoutes.php +++ b/src/Tools/AsciiRoutes.php @@ -1,8 +1,7 @@ templating->addFilter('chr', 'chr'); $this->templating->addFilter('decoct', 'decoct'); @@ -19,7 +18,7 @@ class AsciiRoutes extends RouteHandler { return $this->templating->render('ascii/index'); } - #[Route('GET', '/ascii.php')] + #[HttpGet('/ascii.php')] public function getAsciiPHP($response, $request): void { $response->redirect('/ascii', true); } diff --git a/src/Tools/RandomStringRoutes.php b/src/Tools/RandomStringRoutes.php index 07df8a2..3edd59a 100644 --- a/src/Tools/RandomStringRoutes.php +++ b/src/Tools/RandomStringRoutes.php @@ -2,11 +2,10 @@ namespace Makai\Tools; use Index\XString; -use Index\Routing\Route; -use Index\Routing\RouteHandler; +use Index\Http\Routing\{HttpGet,RouteHandler}; class RandomStringRoutes extends RouteHandler { - #[Route('GET', '/rngstr')] + #[HttpGet('/rngstr')] public function getRandomString($response, $request): string { $response->setTypePlain(); @@ -23,7 +22,7 @@ class RandomStringRoutes extends RouteHandler { return $out; } - #[Route('GET', '/key.php')] + #[HttpGet('/key.php')] public function getKeyPHP($response, $request): void { $url = '/rngstr'; diff --git a/src/Whois/WhoisRoutes.php b/src/Whois/WhoisRoutes.php index e0c7be8..0c67d71 100644 --- a/src/Whois/WhoisRoutes.php +++ b/src/Whois/WhoisRoutes.php @@ -3,8 +3,7 @@ namespace Makai\Whois; use Exception; use Memcached; -use Index\Routing\Route; -use Index\Routing\RouteHandler; +use Index\Http\Routing\{HttpGet,HttpPost,RouteHandler}; use Sasae\SasaeEnvironment; use Makai\CSRFPContainer; @@ -14,12 +13,12 @@ class WhoisRoutes extends RouteHandler { private CSRFPContainer $csrfp, ) {} - #[Route('GET', '/whois')] + #[HttpGet('/whois')] public function getIndex(): string { return $this->templating->render('whois/index'); } - #[Route('POST', '/whois/lookup')] + #[HttpPost('/whois/lookup')] public function postLookup($response, $request): array { if(!$request->isFormContent()) return 400;