Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Add `Softonic\Laravel\Middleware\RequestId::class` in `App\Http\Kernel`.
For all routes:
```php
protected $middleware = [
Softonic\Laravel\Middleware\RequestId::class,
\Softonic\Laravel\Middleware\RequestId::class,
....
]
```
Expand All @@ -26,7 +26,7 @@ Specific group:
// Example for WEB group
protected $middlewareGroups = [
'web' => [
Softonic\Laravel\Middleware\RequestId::class,
\Softonic\Laravel\Middleware\RequestId::class,
...
],

Expand All @@ -49,4 +49,9 @@ Register the middleware as a route middleware in `App\Http\Kernel`.
then, use it in your routes file, for example in `routes\web.php`
```php
Route::get('route', function() {})->middleware('request-id');
```
```

### Extra

If you need to have the X-Request-Id ASAP, you can modify `\App\Providers\AppServiceProvider::boot` adding `$_SERVER['HTTP_X_REQUEST_ID'] ??= \Ramsey\Uuid\Uuid::uuid4()->toString();`.
This is going to allow you to use the X-Request-ID in the framework booting to for example customize monolog or in console executions.
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
"license": "Apache-2.0",
"type": "library",
"require": {
"php": ">=7.0",
"illuminate/http": "^5.3",
"ramsey/uuid": "^3.5"
"php": ">=7.4",
"illuminate/http": ">7.0",
"ramsey/uuid": "^4.0.0"
},
"require-dev": {
"phpunit/phpunit": "^6.0"
"phpunit/phpunit": "^9.0"
},
"autoload": {
"psr-4": {
Expand Down