alitindrawan24 / laravel-request-id
1.0.2.0
2024-05-18 15:57 UTC
Requires
- php: ^7.4|^8.0
- illuminate/support: ^8.0|^9.0|^10.0
Requires (Dev)
- orchestra/testbench: ^6.27
- pestphp/pest: ^1.23
- pestphp/pest-plugin-laravel: ^1.4
README
Request ID is uniquely identifies the HTTP request sent from the app to the service and enables the app to correlate requests and responses, in case the app needs to resend a request because of a dropped connection. This package provides a middleware that allows to generate a unique request id and append on log context every time if the log called.
Installation
You can install the package via composer:
composer require alitindrawan24/laravel-request-id
You can publish the config file with:
php artisan vendor:publish --provider="Alitindrawan24\RequestID\RequestIDServiceProvider" --tag="config"
Usage
This packages provides a middleware which can be added as a global middleware or as a single route.
// in `app/Http/Kernel.php` protected $middleware = [ // ... \Alitindrawan24\RequestID\Middleware\RequestIDMiddleware::class ];
// in a routes file Route::post('/dashboard', function () { // })->middleware(\Alitindrawan24\RequestID\Middleware\RequestIDMiddleware::class);
Testing
composer test
License
This project is licensed under the MIT License - see the LICENSE.md file for details.