承接 revangelista/laravel-idempotency 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

revangelista/laravel-idempotency

最新稳定版本:1.0.0

Composer 安装命令:

composer require revangelista/laravel-idempotency

包简介

Laravel Idempotency Middleware

README 文档

README

Install

Require this package with composer using the following command:

composer require revangelista/laravel-idempotency 

Usage

Register Idempotency middleware on your http kernel file:

'api' => [
    'throttle:60,1',
    'bindings',
    \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 POST, 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, it is strongly suggest to use 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.

To personalise the idempotency header name and the key expiration, publish config file:

php artisan vendor:publish --provider "Idempotency\IdempotencyServiceProvider"

And specify in the .env file like this:

IDEMPOTENCY_HEADER="My-Custom-Idempotency-Key",
IDEMPOTENCY_EXPIRATION=1440 #in minutes

Learn more about Idempotency.

License

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

统计信息

  • 总下载量: 10.44k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 11
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 11
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-05-07