mirror of
https://github.com/sigmasternchen/useful-api.org
synced 2025-03-15 07:58:55 +00:00
feat: Add punycode API
This commit is contained in:
parent
f5d3f75d2e
commit
a2120cb99d
3 changed files with 15 additions and 2 deletions
12
controllers/punycode/GET.php
Normal file
12
controllers/punycode/GET.php
Normal file
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
|
||||
return function (array $context) {
|
||||
if (key_exists("to", $_GET)) {
|
||||
$context["renderer"](idn_to_ascii($_GET["to"]));
|
||||
} elseif (key_exists("from", $_GET)) {
|
||||
$context["renderer"](idn_to_utf8($_GET["from"]));
|
||||
} else {
|
||||
setStatusCode(400);
|
||||
$context["renderer"](errorResponse("Unknown mode", "Please specify one of the following query parameters: to, from"));
|
||||
}
|
||||
};
|
|
@ -13,6 +13,7 @@ return function(Router $router) {
|
|||
$router->addRoute(GET, "/test", useRenderer(fromController("/test/GET")));
|
||||
|
||||
$router->addRoute(GET, "/ipaddress", useRenderer(fromController("/ipaddress/GET")));
|
||||
|
||||
$router->addRoute(GET, "/whois", useRenderer(fromController("/whois/GET")));
|
||||
|
||||
$router->addRoute(GET, "/punycode", useRenderer(fromController("/punycode/GET")));
|
||||
};
|
||||
|
|
|
@ -110,7 +110,7 @@ return function (array $context) {
|
|||
$result = whoisDomain($domain);
|
||||
} else {
|
||||
setStatusCode(400);
|
||||
$result = errorResponse("Unknown mode", "Please specify one of the following query parameters: ip");
|
||||
$result = errorResponse("Unknown mode", "Please specify one of the following query parameters: ip, domain");
|
||||
}
|
||||
|
||||
$context["renderer"]($result);
|
||||
|
|
Loading…
Reference in a new issue