1. Go to this page and download the library: Download ensi/initiator-propagation library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ensi / initiator-propagation example snippets
use Ensi\InitialEventPropagation\InitialEventHolder;
use Ensi\InitialEventPropagation\InitialEventDTO;
InitialEventHolder::getInstance()
->setInitialEvent(
InitialEventDTO::fromScratch(
userId: "1",
userType: "admin",
app: "mobile-api-gateway",
entrypoint: "/api/v1/users/{id}"
)
);
use Ensi\InitialEventPropagation\Config;
use Ensi\InitialEventPropagation\InitialEventHolder;
use Ensi\InitialEventPropagation\InitialEventDTO;
InitialEventHolder::getInstance()
->setInitialEvent(
InitialEventDTO::fromSerializedString($request->header(Config::REQUEST_HEADER))
);
use Ensi\InitialEventPropagation\Config;
use Ensi\InitialEventPropagation\InitialEventHolder;
function some_middleware(callable $handler)
{
return function (RequestInterface $request, $options) use ($handler) {
$inititiator = InitialEventHolder::getInstance()->getInitialEvent();
return $handler(
$inititiator ? $request->withHeader(Config::REQUEST_HEADER, $inititiator->serialize()) : $request,
$options
);
};
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.