mirror of
https://github.com/sigmasternchen/useful-api.org
synced 2025-03-15 16:08:55 +00:00
20 lines
No EOL
479 B
PHP
20 lines
No EOL
479 B
PHP
<?php
|
|
|
|
require_once(ROOT . "/persistence/models/LogEntry.php");
|
|
|
|
function useLog($handler, string $endpoint) {
|
|
return function (array $context) use ($handler, $endpoint) {
|
|
$result = $handler($context);
|
|
|
|
$accessKey = $context["ACCESS_KEY"] ?? "";
|
|
|
|
$entry = new LogEntry(
|
|
$endpoint,
|
|
$_SERVER['REMOTE_ADDR'],
|
|
$accessKey,
|
|
);
|
|
$context[REPOSITORIES]->logs()->add($entry);
|
|
|
|
return $result;
|
|
};
|
|
} |