All Projects → javidalpe → laravel-idempotency

javidalpe / laravel-idempotency

Licence: MIT license
Laravel Idempotency Middleware

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to laravel-idempotency

one
🚥 Idempotency Handler, for making sure incoming requests are idempotent. Useful for payments, "at least once delivery" systems and more.
Stars: ✭ 18 (-18.18%)
Mutual labels:  idempotent, idempotency
Doramon
个人工具汇总:一致性哈希工具,Bitmap工具,布隆过滤器参数生成器,Yaml和properties互转工具,一键式生成整个前后端工具,单机高性能幂等工具,zookeeper客户端工具,分布式全局id生成器,时间转换工具,Http封装工具
Stars: ✭ 53 (+140.91%)
Mutual labels:  idempotency
weweibuy-framework
基于Springboot 封装的基础组件, 包括: Http请求响应日志,日志脱敏,APM, 加解密,签名(AES,BCrypt,RSA,JWT),数据库脱敏,报文脱敏,下滑线风格URL传参,统一异常处理,feign mock,feign日志,feign报文风格转换,跨应用异常上抛,自动补偿组件,幂等组件,RocketMq客户端
Stars: ✭ 24 (+9.09%)
Mutual labels:  idempotent
rack-idempotency
Rack middleware for idempotency guarantees in mutating endpoints.
Stars: ✭ 20 (-9.09%)
Mutual labels:  idempotent
Jdempotent
Make your consumer, API, etc. idempotent easily.
Stars: ✭ 62 (+181.82%)
Mutual labels:  idempotency

Laravel Idempotent Requests

First, what is Idempotency and why I need it?

Checkout this awesome post from Brandum Leach.

Install

Require this package with composer using the following command:

composer require javidalpe/laravel-idempotency 

Usage

Register Idempotency middleware on your http kernel file:

'api' => [
    'throttle:60,1',
    'bindings',
    \Javidalpe\Idempotency\Idempotency::class,
], 

To perform an idempotent request, provide an additional Idempotency-Key: <key> header to the request.

How it works

If the header Idempotency-Key is present on the request and the request method is different from GET, PUT and DELETE, the middleware stores the response on the cache. Next time you make a request with same idempotency key, the middleware will return the cached response.

How you create unique keys is up to you, but I suggest using V4 UUIDs or another appropriately random string. It'll always send back the same response for requests made with the same key, and keys can't be reused with different request parameters. Keys expire after 24 hours.

License

The Laravel Idempotency is open-sourced software licensed under the MIT license

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].