alitindrawan24/laravel-request-id

1.0.2.0 2024-05-18 15:57 UTC

This package is auto-updated.

Last update: 2024-10-18 16:56:32 UTC


README

Latest Version on Packagist Total Downloads License: MIT

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.

Contributors