eufaturo / idempotency-middleware
Idempotency middleware for your Laravel API.
dev-main / 1.0.x-dev
2025-06-09 18:33 UTC
Requires
- php: ^8.4
- illuminate/cache: ^12.0
- illuminate/contracts: ^12.0
- illuminate/database: ^12.0
- illuminate/http: ^12.0
- illuminate/support: ^12.0
- nesbot/carbon: ^3.9
- ramsey/uuid: ^4.8
- symfony/http-foundation: ^7.3
Requires (Dev)
- eufaturo/coding-standards: dev-main
- orchestra/testbench: ^10.0
- phpunit/phpunit: ^11.0
This package is auto-updated.
Last update: 2025-06-09 18:33:58 UTC
README
Introduction
Simple Laravel middleware for implementing idempotency in your API requests
Installation
This library is installed via Composer and to install, run the following command.
composer require eufaturo/idempotency-middleware
Usage
Apply the middleware in your routes or route groups in your, here's a simple example:
<?php use Eufaturo\IdempotencyMiddleware\Idempotency; Route::middleware(['auth:api', Idempotency::class])->group(function () { Route::post('/create-user', function () { // Create the user ... }); });
Usage with HTTP Requests
To perform an idempotent request, provide an additional Idempotency-Key
header through the request options where the value should be a valid UUID v4
Example:
POST /api/create-user HTTP/1.1 Content-Type: application/json Idempotency-Key: 6b3fd36c-24c6-4eb2-a764-bb6c91b33e56 { "name": "John Doe", "email": "john.doe@example.com", "password: "secret" }
Testing
composer test
Contributing
Thank you for your interest. Here are some of the many ways to contribute.
- Check out our contributing guide
- Look at our code of conduct
License
This library is open-sourced software licensed under the MIT license.