new router event

This commit is contained in:
flash 2024-03-30 01:16:42 +00:00
parent 40819d76cf
commit 9741345a08
10 changed files with 116 additions and 137 deletions

156
composer.lock generated
View file

@ -62,7 +62,7 @@
"source": { "source": {
"type": "git", "type": "git",
"url": "https://patchii.net/flash/index.git", "url": "https://patchii.net/flash/index.git",
"reference": "e31781c69f0b13fe251771c8e7e529222630a44f" "reference": "9d5b050b8928435416a7efbebe2a19ae8e626224"
}, },
"require": { "require": {
"ext-mbstring": "*", "ext-mbstring": "*",
@ -100,7 +100,7 @@
], ],
"description": "Composer package for the common library for my projects.", "description": "Composer package for the common library for my projects.",
"homepage": "https://railgun.sh/index", "homepage": "https://railgun.sh/index",
"time": "2023-11-20T19:01:19+00:00" "time": "2024-03-28T23:27:04+00:00"
}, },
{ {
"name": "flashwave/sasae", "name": "flashwave/sasae",
@ -108,7 +108,7 @@
"source": { "source": {
"type": "git", "type": "git",
"url": "https://patchii.net/flash/sasae.git", "url": "https://patchii.net/flash/sasae.git",
"reference": "b56dd222acb8f138729e6258d4a90bbb8401ff52" "reference": "c8a9f2974e6591215b3f898dd5525de1e8367f66"
}, },
"require": { "require": {
"flashwave/index": "dev-master", "flashwave/index": "dev-master",
@ -141,7 +141,7 @@
], ],
"description": "A wrapper for Twig with added common functionality.", "description": "A wrapper for Twig with added common functionality.",
"homepage": "https://railgun.sh/sasae", "homepage": "https://railgun.sh/sasae",
"time": "2023-11-20T19:09:35+00:00" "time": "2024-01-04T02:13:42+00:00"
}, },
{ {
"name": "flashwave/syokuhou", "name": "flashwave/syokuhou",
@ -149,7 +149,7 @@
"source": { "source": {
"type": "git", "type": "git",
"url": "https://patchii.net/flash/syokuhou.git", "url": "https://patchii.net/flash/syokuhou.git",
"reference": "fdf3c38cc216bf7024af331cbe1758532355c22f" "reference": "c1fe9371ada20fcea51c225cc53b9ceae4642bc4"
}, },
"require": { "require": {
"flashwave/index": "dev-master", "flashwave/index": "dev-master",
@ -180,7 +180,7 @@
], ],
"description": "Configuration library for PHP.", "description": "Configuration library for PHP.",
"homepage": "https://railgun.sh/syokuhou", "homepage": "https://railgun.sh/syokuhou",
"time": "2023-11-20T19:10:04+00:00" "time": "2024-01-04T02:12:49+00:00"
}, },
{ {
"name": "guzzlehttp/psr7", "name": "guzzlehttp/psr7",
@ -300,16 +300,16 @@
}, },
{ {
"name": "jean85/pretty-package-versions", "name": "jean85/pretty-package-versions",
"version": "2.0.5", "version": "2.0.6",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/Jean85/pretty-package-versions.git", "url": "https://github.com/Jean85/pretty-package-versions.git",
"reference": "ae547e455a3d8babd07b96966b17d7fd21d9c6af" "reference": "f9fdd29ad8e6d024f52678b570e5593759b550b4"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/Jean85/pretty-package-versions/zipball/ae547e455a3d8babd07b96966b17d7fd21d9c6af", "url": "https://api.github.com/repos/Jean85/pretty-package-versions/zipball/f9fdd29ad8e6d024f52678b570e5593759b550b4",
"reference": "ae547e455a3d8babd07b96966b17d7fd21d9c6af", "reference": "f9fdd29ad8e6d024f52678b570e5593759b550b4",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -317,9 +317,9 @@
"php": "^7.1|^8.0" "php": "^7.1|^8.0"
}, },
"require-dev": { "require-dev": {
"friendsofphp/php-cs-fixer": "^2.17", "friendsofphp/php-cs-fixer": "^3.2",
"jean85/composer-provided-replaced-stub-package": "^1.0", "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", "phpunit/phpunit": "^7.5|^8.5|^9.4",
"vimeo/psalm": "^4.3" "vimeo/psalm": "^4.3"
}, },
@ -353,9 +353,9 @@
], ],
"support": { "support": {
"issues": "https://github.com/Jean85/pretty-package-versions/issues", "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", "name": "psr/http-factory",
@ -616,16 +616,16 @@
}, },
{ {
"name": "sentry/sentry", "name": "sentry/sentry",
"version": "4.1.0", "version": "4.6.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/getsentry/sentry-php.git", "url": "https://github.com/getsentry/sentry-php.git",
"reference": "89666f297891ff937fceb2f3d1fb967a6848cf37" "reference": "5a94184175e5830b589bf923da8c9c3af2c0f409"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/getsentry/sentry-php/zipball/89666f297891ff937fceb2f3d1fb967a6848cf37", "url": "https://api.github.com/repos/getsentry/sentry-php/zipball/5a94184175e5830b589bf923da8c9c3af2c0f409",
"reference": "89666f297891ff937fceb2f3d1fb967a6848cf37", "reference": "5a94184175e5830b589bf923da8c9c3af2c0f409",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -649,7 +649,7 @@
"phpbench/phpbench": "^1.0", "phpbench/phpbench": "^1.0",
"phpstan/phpstan": "^1.3", "phpstan/phpstan": "^1.3",
"phpunit/phpunit": "^8.5.14|^9.4", "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" "vimeo/psalm": "^4.17"
}, },
"suggest": { "suggest": {
@ -689,7 +689,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/getsentry/sentry-php/issues", "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": [ "funding": [
{ {
@ -701,7 +701,7 @@
"type": "custom" "type": "custom"
} }
], ],
"time": "2023-12-04T12:41:21+00:00" "time": "2024-03-08T08:18:09+00:00"
}, },
{ {
"name": "symfony/deprecation-contracts", "name": "symfony/deprecation-contracts",
@ -772,16 +772,16 @@
}, },
{ {
"name": "symfony/mime", "name": "symfony/mime",
"version": "v7.0.0", "version": "v7.0.3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/mime.git", "url": "https://github.com/symfony/mime.git",
"reference": "0a2fff95c1a10df97f571d67e76c7ae0f0d4f535" "reference": "c1ffe24ba6fdc3e3f0f3fcb93519103b326a3716"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/mime/zipball/0a2fff95c1a10df97f571d67e76c7ae0f0d4f535", "url": "https://api.github.com/repos/symfony/mime/zipball/c1ffe24ba6fdc3e3f0f3fcb93519103b326a3716",
"reference": "0a2fff95c1a10df97f571d67e76c7ae0f0d4f535", "reference": "c1ffe24ba6fdc3e3f0f3fcb93519103b326a3716",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -835,7 +835,7 @@
"mime-type" "mime-type"
], ],
"support": { "support": {
"source": "https://github.com/symfony/mime/tree/v7.0.0" "source": "https://github.com/symfony/mime/tree/v7.0.3"
}, },
"funding": [ "funding": [
{ {
@ -851,7 +851,7 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2023-10-19T14:20:43+00:00" "time": "2024-01-30T08:34:29+00:00"
}, },
{ {
"name": "symfony/options-resolver", "name": "symfony/options-resolver",
@ -922,16 +922,16 @@
}, },
{ {
"name": "symfony/polyfill-ctype", "name": "symfony/polyfill-ctype",
"version": "v1.28.0", "version": "v1.29.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/polyfill-ctype.git", "url": "https://github.com/symfony/polyfill-ctype.git",
"reference": "ea208ce43cbb04af6867b4fdddb1bdbf84cc28cb" "reference": "ef4d7e442ca910c4764bce785146269b30cb5fc4"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/ea208ce43cbb04af6867b4fdddb1bdbf84cc28cb", "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/ef4d7e442ca910c4764bce785146269b30cb5fc4",
"reference": "ea208ce43cbb04af6867b4fdddb1bdbf84cc28cb", "reference": "ef4d7e442ca910c4764bce785146269b30cb5fc4",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -945,9 +945,6 @@
}, },
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": {
"dev-main": "1.28-dev"
},
"thanks": { "thanks": {
"name": "symfony/polyfill", "name": "symfony/polyfill",
"url": "https://github.com/symfony/polyfill" "url": "https://github.com/symfony/polyfill"
@ -984,7 +981,7 @@
"portable" "portable"
], ],
"support": { "support": {
"source": "https://github.com/symfony/polyfill-ctype/tree/v1.28.0" "source": "https://github.com/symfony/polyfill-ctype/tree/v1.29.0"
}, },
"funding": [ "funding": [
{ {
@ -1000,20 +997,20 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2023-01-26T09:26:14+00:00" "time": "2024-01-29T20:11:03+00:00"
}, },
{ {
"name": "symfony/polyfill-intl-idn", "name": "symfony/polyfill-intl-idn",
"version": "v1.28.0", "version": "v1.29.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/polyfill-intl-idn.git", "url": "https://github.com/symfony/polyfill-intl-idn.git",
"reference": "ecaafce9f77234a6a449d29e49267ba10499116d" "reference": "a287ed7475f85bf6f61890146edbc932c0fff919"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/ecaafce9f77234a6a449d29e49267ba10499116d", "url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/a287ed7475f85bf6f61890146edbc932c0fff919",
"reference": "ecaafce9f77234a6a449d29e49267ba10499116d", "reference": "a287ed7475f85bf6f61890146edbc932c0fff919",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1026,9 +1023,6 @@
}, },
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": {
"dev-main": "1.28-dev"
},
"thanks": { "thanks": {
"name": "symfony/polyfill", "name": "symfony/polyfill",
"url": "https://github.com/symfony/polyfill" "url": "https://github.com/symfony/polyfill"
@ -1071,7 +1065,7 @@
"shim" "shim"
], ],
"support": { "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": [ "funding": [
{ {
@ -1087,20 +1081,20 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2023-01-26T09:30:37+00:00" "time": "2024-01-29T20:11:03+00:00"
}, },
{ {
"name": "symfony/polyfill-intl-normalizer", "name": "symfony/polyfill-intl-normalizer",
"version": "v1.28.0", "version": "v1.29.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/polyfill-intl-normalizer.git", "url": "https://github.com/symfony/polyfill-intl-normalizer.git",
"reference": "8c4ad05dd0120b6a53c1ca374dca2ad0a1c4ed92" "reference": "bc45c394692b948b4d383a08d7753968bed9a83d"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/8c4ad05dd0120b6a53c1ca374dca2ad0a1c4ed92", "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/bc45c394692b948b4d383a08d7753968bed9a83d",
"reference": "8c4ad05dd0120b6a53c1ca374dca2ad0a1c4ed92", "reference": "bc45c394692b948b4d383a08d7753968bed9a83d",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1111,9 +1105,6 @@
}, },
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": {
"dev-main": "1.28-dev"
},
"thanks": { "thanks": {
"name": "symfony/polyfill", "name": "symfony/polyfill",
"url": "https://github.com/symfony/polyfill" "url": "https://github.com/symfony/polyfill"
@ -1155,7 +1146,7 @@
"shim" "shim"
], ],
"support": { "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": [ "funding": [
{ {
@ -1171,20 +1162,20 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2023-01-26T09:26:14+00:00" "time": "2024-01-29T20:11:03+00:00"
}, },
{ {
"name": "symfony/polyfill-mbstring", "name": "symfony/polyfill-mbstring",
"version": "v1.28.0", "version": "v1.29.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/polyfill-mbstring.git", "url": "https://github.com/symfony/polyfill-mbstring.git",
"reference": "42292d99c55abe617799667f454222c54c60e229" "reference": "9773676c8a1bb1f8d4340a62efe641cf76eda7ec"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/42292d99c55abe617799667f454222c54c60e229", "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/9773676c8a1bb1f8d4340a62efe641cf76eda7ec",
"reference": "42292d99c55abe617799667f454222c54c60e229", "reference": "9773676c8a1bb1f8d4340a62efe641cf76eda7ec",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1198,9 +1189,6 @@
}, },
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": {
"dev-main": "1.28-dev"
},
"thanks": { "thanks": {
"name": "symfony/polyfill", "name": "symfony/polyfill",
"url": "https://github.com/symfony/polyfill" "url": "https://github.com/symfony/polyfill"
@ -1238,7 +1226,7 @@
"shim" "shim"
], ],
"support": { "support": {
"source": "https://github.com/symfony/polyfill-mbstring/tree/v1.28.0" "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.29.0"
}, },
"funding": [ "funding": [
{ {
@ -1254,20 +1242,20 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2023-07-28T09:04:16+00:00" "time": "2024-01-29T20:11:03+00:00"
}, },
{ {
"name": "symfony/polyfill-php72", "name": "symfony/polyfill-php72",
"version": "v1.28.0", "version": "v1.29.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/polyfill-php72.git", "url": "https://github.com/symfony/polyfill-php72.git",
"reference": "70f4aebd92afca2f865444d30a4d2151c13c3179" "reference": "861391a8da9a04cbad2d232ddd9e4893220d6e25"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/70f4aebd92afca2f865444d30a4d2151c13c3179", "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/861391a8da9a04cbad2d232ddd9e4893220d6e25",
"reference": "70f4aebd92afca2f865444d30a4d2151c13c3179", "reference": "861391a8da9a04cbad2d232ddd9e4893220d6e25",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1275,9 +1263,6 @@
}, },
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": {
"dev-main": "1.28-dev"
},
"thanks": { "thanks": {
"name": "symfony/polyfill", "name": "symfony/polyfill",
"url": "https://github.com/symfony/polyfill" "url": "https://github.com/symfony/polyfill"
@ -1314,7 +1299,7 @@
"shim" "shim"
], ],
"support": { "support": {
"source": "https://github.com/symfony/polyfill-php72/tree/v1.28.0" "source": "https://github.com/symfony/polyfill-php72/tree/v1.29.0"
}, },
"funding": [ "funding": [
{ {
@ -1330,20 +1315,20 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2023-01-26T09:26:14+00:00" "time": "2024-01-29T20:11:03+00:00"
}, },
{ {
"name": "symfony/polyfill-php80", "name": "symfony/polyfill-php80",
"version": "v1.28.0", "version": "v1.29.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/polyfill-php80.git", "url": "https://github.com/symfony/polyfill-php80.git",
"reference": "6caa57379c4aec19c0a12a38b59b26487dcfe4b5" "reference": "87b68208d5c1188808dd7839ee1e6c8ec3b02f1b"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/6caa57379c4aec19c0a12a38b59b26487dcfe4b5", "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/87b68208d5c1188808dd7839ee1e6c8ec3b02f1b",
"reference": "6caa57379c4aec19c0a12a38b59b26487dcfe4b5", "reference": "87b68208d5c1188808dd7839ee1e6c8ec3b02f1b",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1351,9 +1336,6 @@
}, },
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": {
"dev-main": "1.28-dev"
},
"thanks": { "thanks": {
"name": "symfony/polyfill", "name": "symfony/polyfill",
"url": "https://github.com/symfony/polyfill" "url": "https://github.com/symfony/polyfill"
@ -1397,7 +1379,7 @@
"shim" "shim"
], ],
"support": { "support": {
"source": "https://github.com/symfony/polyfill-php80/tree/v1.28.0" "source": "https://github.com/symfony/polyfill-php80/tree/v1.29.0"
}, },
"funding": [ "funding": [
{ {
@ -1413,7 +1395,7 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2023-01-26T09:26:14+00:00" "time": "2024-01-29T20:11:03+00:00"
}, },
{ {
"name": "twig/html-extra", "name": "twig/html-extra",
@ -1555,16 +1537,16 @@
"packages-dev": [ "packages-dev": [
{ {
"name": "phpstan/phpstan", "name": "phpstan/phpstan",
"version": "1.10.50", "version": "1.10.66",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/phpstan/phpstan.git", "url": "https://github.com/phpstan/phpstan.git",
"reference": "06a98513ac72c03e8366b5a0cb00750b487032e4" "reference": "94779c987e4ebd620025d9e5fdd23323903950bd"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/06a98513ac72c03e8366b5a0cb00750b487032e4", "url": "https://api.github.com/repos/phpstan/phpstan/zipball/94779c987e4ebd620025d9e5fdd23323903950bd",
"reference": "06a98513ac72c03e8366b5a0cb00750b487032e4", "reference": "94779c987e4ebd620025d9e5fdd23323903950bd",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1613,7 +1595,7 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2023-12-13T10:59:42+00:00" "time": "2024-03-28T16:17:31+00:00"
} }
], ],
"aliases": [], "aliases": [],
@ -1627,5 +1609,5 @@
"prefer-lowest": false, "prefer-lowest": false,
"platform": [], "platform": [],
"platform-dev": [], "platform-dev": [],
"plugin-api-version": "2.3.0" "plugin-api-version": "2.6.0"
} }

View file

@ -1,15 +1,14 @@
<?php <?php
namespace Makai; namespace Makai;
use Index\Routing\Route; use Index\Http\Routing\{HttpGet,RouteHandler};
use Index\Routing\RouteHandler;
class AssetsRoutes extends RouteHandler { class AssetsRoutes extends RouteHandler {
public function __construct( public function __construct(
private SiteInfo $siteInfo private SiteInfo $siteInfo
) {} ) {}
#[Route('GET', '/header-bgs.json')] #[HttpGet('/header-bgs.json')]
public function getHeaderImages(): array { public function getHeaderImages(): array {
return $this->siteInfo->getHeaderImages(); return $this->siteInfo->getHeaderImages();
} }

View file

@ -1,8 +1,7 @@
<?php <?php
namespace Makai; namespace Makai;
use Index\Routing\Route; use Index\Http\Routing\{HttpGet,RouteHandler};
use Index\Routing\RouteHandler;
use Sasae\SasaeEnvironment; use Sasae\SasaeEnvironment;
use Makai\Contacts\Contacts; use Makai\Contacts\Contacts;
use Makai\Projects\Projects; use Makai\Projects\Projects;
@ -14,7 +13,7 @@ class DeveloperRoutes extends RouteHandler {
private Projects $projects private Projects $projects
) {} ) {}
#[Route('GET', '/')] #[HttpGet('/')]
public function getIndex($response, $request) { public function getIndex($response, $request) {
$projectInfos = $this->projects->getProjects( $projectInfos = $this->projects->getProjects(
featuredOnly: true, featuredOnly: true,
@ -41,19 +40,19 @@ class DeveloperRoutes extends RouteHandler {
]); ]);
} }
#[Route('GET', '/home')] #[HttpGet('/home')]
public function getPersonalHome(): string { public function getPersonalHome(): string {
return $this->templating->render('dev/home'); return $this->templating->render('dev/home');
} }
#[Route('GET', '/contact')] #[HttpGet('/contact')]
public function getContact(): string { public function getContact(): string {
return $this->templating->render('dev/contact', [ return $this->templating->render('dev/contact', [
'contacts' => $this->contacts->getContacts(), 'contacts' => $this->contacts->getContacts(),
]); ]);
} }
#[Route('GET', '/projects')] #[HttpGet('/projects')]
public function getProjects(): string { public function getProjects(): string {
$projectInfos = $this->projects->getProjects(deleted: false); $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 { public function getNowListening($response, $request): string {
return $this->templating->render('dev/np', [ return $this->templating->render('dev/np', [
'header_offset' => (int)$request->getParam('offset', FILTER_SANITIZE_NUMBER_INT), 'header_offset' => (int)$request->getParam('offset', FILTER_SANITIZE_NUMBER_INT),

View file

@ -89,8 +89,7 @@ final class MakaiContext {
} }
public function createRouting(): RoutingContext { public function createRouting(): RoutingContext {
$routingCtx = new RoutingContext($this->templating); $routingCtx = new RoutingContext;
$routingCtx->registerDefaultErrorPages();
$routingCtx->register(new DeveloperRoutes($this->templating, $this->contacts, $this->projects)); $routingCtx->register(new DeveloperRoutes($this->templating, $this->contacts, $this->projects));
$routingCtx->register(new AssetsRoutes($this->siteInfo)); $routingCtx->register(new AssetsRoutes($this->siteInfo));

View file

@ -1,19 +1,14 @@
<?php <?php
namespace Makai; namespace Makai;
use Index\Http\HttpFx; use Index\Http\Routing\{HttpRouter,IRouter,IRouteHandler};
use Index\Http\HttpRequest;
use Index\Routing\IRouter;
use Index\Routing\IRouteHandler;
use Sasae\SasaeEnvironment; use Sasae\SasaeEnvironment;
class RoutingContext { class RoutingContext {
private HttpFx $router; private HttpRouter $router;
private SasaeEnvironment $templating;
public function __construct(SasaeEnvironment $templating) { public function __construct() {
$this->templating = $templating; $this->router = new HttpRouter(errorHandler: new RoutingErrorHandler);
$this->router = new HttpFx;
$this->router->use('/', fn($resp) => $resp->setPoweredBy('Makai')); $this->router->use('/', fn($resp) => $resp->setPoweredBy('Makai'));
} }
@ -21,19 +16,11 @@ class RoutingContext {
return $this->router; 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 { public function register(IRouteHandler $handler): void {
$this->router->register($handler); $this->router->register($handler);
} }
public function dispatch(?HttpRequest $request = null): void { public function dispatch(): void {
$this->router->dispatch($request); $this->router->dispatch();
} }
} }

View file

@ -0,0 +1,17 @@
<?php
namespace Makai;
use Index\Http\{HttpResponseBuilder,HttpRequest};
use Index\Http\ErrorHandling\HtmlErrorHandler;
class RoutingErrorHandler extends HtmlErrorHandler {
public function handle(HttpResponseBuilder $response, HttpRequest $request, int $code, string $message): void {
if($code === 401 || $code === 403 || $code === 404 || $code === 500 || $code === 503) {
$response->setTypeHTML();
$response->accelRedirect(sprintf('/error-%s.html', $code));
return;
}
parent::handle($response, $request, $code, $message);
}
}

View file

@ -1,15 +1,14 @@
<?php <?php
namespace Makai\SSHKeys; namespace Makai\SSHKeys;
use Index\Routing\Route; use Index\Http\Routing\{HttpGet,RouteHandler};
use Index\Routing\RouteHandler;
class SSHKeysRoutes extends RouteHandler { class SSHKeysRoutes extends RouteHandler {
public function __construct( public function __construct(
private SSHKeys $sshKeys private SSHKeys $sshKeys
) {} ) {}
#[Route('GET', '/ssh_keys')] #[HttpGet('/ssh_keys')]
public function getSshKeys($response, $request): array|string { public function getSshKeys($response, $request): array|string {
$minLevel = (int)$request->getParam('l', FILTER_SANITIZE_NUMBER_INT); $minLevel = (int)$request->getParam('l', FILTER_SANITIZE_NUMBER_INT);
$includeComment = $request->hasParam('c'); $includeComment = $request->hasParam('c');
@ -43,7 +42,7 @@ class SSHKeysRoutes extends RouteHandler {
return $body; return $body;
} }
#[Route('GET', '/authorized_keys')] #[HttpGet('/authorized_keys')]
public function getAuthorisedKeys($response, $request): string { public function getAuthorisedKeys($response, $request): string {
$response->setTypePlain(); $response->setTypePlain();
$body = ''; $body = '';
@ -55,7 +54,7 @@ class SSHKeysRoutes extends RouteHandler {
return $body; return $body;
} }
#[Route('GET', '/git_keys_ro')] #[HttpGet('/git_keys_ro')]
public function getGitKeysReadOnly($response, $request): string { public function getGitKeysReadOnly($response, $request): string {
$response->setTypePlain(); $response->setTypePlain();
$body = ''; $body = '';
@ -67,7 +66,7 @@ class SSHKeysRoutes extends RouteHandler {
return $body; return $body;
} }
#[Route('GET', '/git_keys_rw')] #[HttpGet('/git_keys_rw')]
public function getGitKeysReadWrite($response, $request): string { public function getGitKeysReadWrite($response, $request): string {
$response->setTypePlain(); $response->setTypePlain();
$body = ''; $body = '';
@ -79,7 +78,7 @@ class SSHKeysRoutes extends RouteHandler {
return $body; return $body;
} }
#[Route('GET', '/ssh.php')] #[HttpGet('/ssh.php')]
public function getSshPhp($response, $request): void { public function getSshPhp($response, $request): void {
$query = []; $query = [];

View file

@ -1,8 +1,7 @@
<?php <?php
namespace Makai\Tools; namespace Makai\Tools;
use Index\Routing\Route; use Index\Http\Routing\{HttpGet,RouteHandler};
use Index\Routing\RouteHandler;
use Sasae\SasaeEnvironment; use Sasae\SasaeEnvironment;
class AsciiRoutes extends RouteHandler { class AsciiRoutes extends RouteHandler {
@ -10,7 +9,7 @@ class AsciiRoutes extends RouteHandler {
private SasaeEnvironment $templating private SasaeEnvironment $templating
) {} ) {}
#[Route('GET', '/ascii')] #[HttpGet('/ascii')]
public function getAsciiTable($response, $request): string { public function getAsciiTable($response, $request): string {
$this->templating->addFilter('chr', 'chr'); $this->templating->addFilter('chr', 'chr');
$this->templating->addFilter('decoct', 'decoct'); $this->templating->addFilter('decoct', 'decoct');
@ -19,7 +18,7 @@ class AsciiRoutes extends RouteHandler {
return $this->templating->render('ascii/index'); return $this->templating->render('ascii/index');
} }
#[Route('GET', '/ascii.php')] #[HttpGet('/ascii.php')]
public function getAsciiPHP($response, $request): void { public function getAsciiPHP($response, $request): void {
$response->redirect('/ascii', true); $response->redirect('/ascii', true);
} }

View file

@ -2,11 +2,10 @@
namespace Makai\Tools; namespace Makai\Tools;
use Index\XString; use Index\XString;
use Index\Routing\Route; use Index\Http\Routing\{HttpGet,RouteHandler};
use Index\Routing\RouteHandler;
class RandomStringRoutes extends RouteHandler { class RandomStringRoutes extends RouteHandler {
#[Route('GET', '/rngstr')] #[HttpGet('/rngstr')]
public function getRandomString($response, $request): string { public function getRandomString($response, $request): string {
$response->setTypePlain(); $response->setTypePlain();
@ -23,7 +22,7 @@ class RandomStringRoutes extends RouteHandler {
return $out; return $out;
} }
#[Route('GET', '/key.php')] #[HttpGet('/key.php')]
public function getKeyPHP($response, $request): void { public function getKeyPHP($response, $request): void {
$url = '/rngstr'; $url = '/rngstr';

View file

@ -3,8 +3,7 @@ namespace Makai\Whois;
use Exception; use Exception;
use Memcached; use Memcached;
use Index\Routing\Route; use Index\Http\Routing\{HttpGet,HttpPost,RouteHandler};
use Index\Routing\RouteHandler;
use Sasae\SasaeEnvironment; use Sasae\SasaeEnvironment;
use Makai\CSRFPContainer; use Makai\CSRFPContainer;
@ -14,12 +13,12 @@ class WhoisRoutes extends RouteHandler {
private CSRFPContainer $csrfp, private CSRFPContainer $csrfp,
) {} ) {}
#[Route('GET', '/whois')] #[HttpGet('/whois')]
public function getIndex(): string { public function getIndex(): string {
return $this->templating->render('whois/index'); return $this->templating->render('whois/index');
} }
#[Route('POST', '/whois/lookup')] #[HttpPost('/whois/lookup')]
public function postLookup($response, $request): array { public function postLookup($response, $request): array {
if(!$request->isFormContent()) if(!$request->isFormContent())
return 400; return 400;