mirror of
https://github.com/sigmasternchen/useful-api.org
synced 2025-03-15 07:58:55 +00:00
feat: Add ipaddress API
This commit is contained in:
parent
f2f5cb9491
commit
57d39bc02f
5 changed files with 14 additions and 4 deletions
7
controllers/ipaddress/GET.php
Normal file
7
controllers/ipaddress/GET.php
Normal file
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
|
||||
return function (array $context) {
|
||||
$context["renderer"]([
|
||||
"address" => $_SERVER['REMOTE_ADDR'],
|
||||
]);
|
||||
};
|
|
@ -10,5 +10,6 @@ function fromController(string $path) {
|
|||
|
||||
return function(Router $router) {
|
||||
$router->addRoute(GET, "/", fromController("/GET"));
|
||||
$router->addRoute(GET, "/test", useRenderer(fromController("/test/GET"), "JSON"));
|
||||
$router->addRoute(GET, "/test", useRenderer(fromController("/test/GET")));
|
||||
$router->addRoute(GET, "/ipaddress", useRenderer(fromController("/ipaddress/GET")));
|
||||
};
|
||||
|
|
2
core.php
2
core.php
|
@ -4,8 +4,6 @@ const ROOT = __DIR__;
|
|||
|
||||
define("MAINTENANCE_MODE", require(ROOT . "/maintenance.php"));
|
||||
|
||||
require_once(ROOT . "/utils/arrays.php");
|
||||
|
||||
if (MAINTENANCE_MODE) {
|
||||
require(ROOT . "./templates/maintenance.php");
|
||||
} else {
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
|
||||
function useRenderer($handler, string $default, string $query_param = "format") {
|
||||
require_once(ROOT . "/utils/arrays.php");
|
||||
|
||||
function useRenderer($handler, string $default = "JSON", string $query_param = "format") {
|
||||
return function (array $context) use ($handler, $default, $query_param) {
|
||||
$rendererMap = require(ROOT . "/renderer/renderer.php");
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
require_once(ROOT . "/utils/arrays.php");
|
||||
|
||||
const GET = "GET";
|
||||
const POST = "POST";
|
||||
const PUT = "PUT";
|
||||
|
|
Loading…
Reference in a new issue