Skip to content

Commit 70fc12f

Browse files
committed
PUT shouldn't need Idempotence Key
Close #3
1 parent c40b126 commit 70fc12f

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ To perform an idempotent request, provide an additional `Idempotency-Key: <key>`
2828

2929
### How it works
3030

31-
If the header `Idempotency-Key` is present on the request and the request method is different from GET 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.
31+
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.
3232

3333
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.
3434

3535
### License
3636

37-
The Laravel Idempotency is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)
37+
The Laravel Idempotency is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)

src/Idempotency.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
class Idempotency
99
{
1010
const IDEMPOTENCY_HEADER = "Idempotency-Key";
11-
const EXPIRATION_IN_MINUTES = 60*24;
11+
const EXPIRATION_IN_MINUTES = 1440; // 24 hours
1212

1313
/**
1414
* Handle an incoming request.
@@ -19,7 +19,7 @@ class Idempotency
1919
*/
2020
public function handle($request, Closure $next)
2121
{
22-
if ($request->method() == 'GET' || $request->method() == 'DELETE') {
22+
if ($request->method() == 'GET' || $request->method() == 'PUT' || $request->method() == 'DELETE') {
2323
return $next($request);
2424
}
2525

0 commit comments

Comments
 (0)