Skip to content

Commit 0fddffb

Browse files
committed
fixes
1 parent d11df18 commit 0fddffb

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Laravel Inititator Propagation
1+
# Laravel Initial Evenet Propagation
22

33
[![Latest Version on Packagist](https://img.shields.io/packagist/v/ensi/laravel-initial-event-propagation.svg?style=flat-square)](https://packagist.org/packages/ensi/laravel-initial-event-propagation)
44
[![Tests](https://github.com/ensi-platform/laravel-initial-event-propagation/actions/workflows/run-tests.yml/badge.svg?branch=master)](https://github.com/ensi-platform/laravel-initial-event-propagation/actions/workflows/run-tests.yml)
@@ -47,10 +47,10 @@ In practice it likely means that you have to place the middleare at the very bot
4747
#### Parsing incoming initial event
4848

4949
Add `Ensi\LaravelInitialEventPropagation\ParseInitialEventHeaderMiddleware` to `app/Http/Kernel` middleware property.
50-
This middleware parses `X-InitialEvent` HTTP header, deserializes it into `InitialEventDTO` object and places it to the `InitialEventHolder` singleton.
50+
This middleware parses `X-Initial-Event` HTTP header, deserializes it into `InitialEventDTO` object and places it to the `InitialEventHolder` singleton.
5151

5252
#### Propagating initial event to outcomming HTTP request
53-
The package provides a `Ensi\LaravelInitialEventPropagation\PropagateInitialEventLaravelGuzzleMiddleware` Guzzle Middleware that converts ` resolve(InitialEventHolder::class)->getInitialEvent()` back to `X-Inititator` header and sets this header for all outcomming guzzle request.
53+
The package provides a `Ensi\LaravelInitialEventPropagation\PropagateInitialEventLaravelGuzzleMiddleware` Guzzle Middleware that converts ` resolve(InitialEventHolder::class)->getInitialEvent()` back to `X-Initial-Event` header and sets this header for all outcomming guzzle request.
5454

5555
You can add it to your guzzle stack like this:
5656

File renamed without changes.

src/PropagateInitialEventLaravelGuzzleMiddleware.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ class PropagateInitialEventLaravelGuzzleMiddleware
1212
public function __invoke(callable $handler): callable
1313
{
1414
return function (RequestInterface $request, $options) use ($handler) {
15-
$inititiator = Container::getInstance()->make(InitialEventHolder::class)->getInitialEvent();
15+
$initialEvent = Container::getInstance()->make(InitialEventHolder::class)->getInitialEvent();
1616

1717
return $handler(
18-
$inititiator ? $request->withHeader(Config::REQUEST_HEADER, $inititiator->serialize()) : $request,
18+
$initialEvent ? $request->withHeader(Config::REQUEST_HEADER, $initialEvent->serialize()) : $request,
1919
$options
2020
);
2121
};

src/SetInitialEventHttpMiddleware.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,18 @@ public function handle(Request $request, Closure $next): mixed
1414
{
1515
$user = $request->user();
1616
$config = config('initial-event-propagation', []);
17-
$mc = config('initial-event-propagation.set_initiator_http_middleware', []);
17+
$mc = config('initial-event-propagation.set_initial_event_http_middleware', []);
1818

19-
$initiator = InitialEventDTO::fromScratch(
19+
$initialEvent = InitialEventDTO::fromScratch(
2020
userId: $user ? $user->getId() : "",
21-
userType: $user ? config('initial-event-propagation.set_initiator_http_middleware.default_user_type', '') : "",
21+
userType: $user ? $mc['default_user_type'] : "",
2222
app: !empty($mc['app_code_header']) ? $request->header($mc['app_code_header']) : ($config['app_code'] ?? ''),
2323
entrypoint: $this->extractEntrypoint($request),
2424
correlationId: !empty($mc['correlation_id_header']) ? $request->header($mc['correlation_id_header']) : '',
2525
timestamp: !empty($mc['timestamp_header']) ? $request->header($mc['timestamp_header']) : ''
2626
);
2727

28-
Container::getInstance()->make(InitialEventHolder::class)->setInitialEvent($initiator);
28+
Container::getInstance()->make(InitialEventHolder::class)->setInitialEvent($initialEvent);
2929

3030
return $next($request);
3131
}

0 commit comments

Comments
 (0)