yeknava / laravel-idempotent
为 Laravel 设计的幂等中间件
dev-main
2021-07-06 15:41 UTC
Requires
- php: >= 7.1
- ext-json: *
- illuminate/support: 5.5.*|5.6.*|5.7.*|5.8.*|6.*|7.*|8.*
Requires (Dev)
- fzaninotto/faker: ^1.4
- orchestra/testbench: ^5.0
- phpstan/phpstan: ^0.12
- phpunit/phpunit: 9.4.3
This package is not auto-updated.
Last update: 2024-09-26 05:48:13 UTC
README
Laravel 幂等包
安装
使用包管理器 Composer 安装 laravel-idempotent 包。
composer require yeknava/laravel-idempotent
用法
在您的终端运行此命令
php artisan vendor:publish
然后将以下内容添加到 app/Http 文件夹中的 Kernel.php 文件中。
protected $routeMiddleware = [ //... 'idempotent' => \Yeknava\Laravel-Idempotent\Idempotent::class, ];
然后您可以在路由中使用它,如下所示
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' ];
贡献
欢迎提交拉取请求。对于重大更改,请先提交一个问题来讨论您想要进行哪些更改。