Laravel Idempotent Package
Use the package manager composer to install laravel idempotent package.
composer require yeknava/laravel-idempotent
Run this command in your terminal:
php artisan vendor:publish
Then add this to your Kernel.php in app/Http folder.
protected $routeMiddleware = [
//...
'idempotent' => \Yeknava\Laravel-Idempotent\Idempotent::class,
];
then you can use this on your routes like this:
Route::middleware('idempotent')->post('/', function (Request $request) {
return 'hi';
});
<?php
return [
'expires_in' => 86400, //24h
'force' => true, //force idempotent key exists (it wont force on GET method anyway)
'skip_http_methods' => [
'HEAD',
'OPTIONS',
],
'header_key' => 'Idempotency-Key'
];
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.