Skip to content

Commit

Permalink
Implement our own CacheMiddleware class that supports POST requests a…
Browse files Browse the repository at this point in the history
…s well as GET
  • Loading branch information
jblz committed Aug 21, 2024
1 parent e6bce78 commit 40617e4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
13 changes: 13 additions & 0 deletions inc/http-client/class-cache-middleware.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace RemoteDataBlocks\HttpClient;

use Kevinrob\GuzzleCache\CacheMiddleware as GuzzleCacheCacheMiddleware;

class CacheMiddleware extends GuzzleCacheCacheMiddleware {
// phpcs:ignore WordPress.NamingConventions.ValidVariableName.PropertyNotSnakeCase
protected $httpMethods = [
'GET' => true,
'POST' => true,
];
}
2 changes: 1 addition & 1 deletion inc/http-client/class-http-client.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
use GuzzleHttp\MessageFormatter;
use GuzzleHttp\Middleware;
use GuzzleHttp\Promise\Utils;
use Kevinrob\GuzzleCache\CacheMiddleware;
use Kevinrob\GuzzleCache\KeyValueHttpHeader;
use Kevinrob\GuzzleCache\Storage\WordPressObjectCacheStorage;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\UriInterface;
use RemoteDataBlocks\HttpClient\CacheMiddleware;
use RemoteDataBlocks\HttpClient\CacheStrategy;
use RemoteDataBlocks\Logging\LoggerManager;

Expand Down
1 change: 1 addition & 0 deletions inc/http-client/http-client.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

require_once __DIR__ . '/class-cache-middleware.php';
require_once __DIR__ . '/class-cache-strategy.php';
require_once __DIR__ . '/class-http-client.php';

0 comments on commit 40617e4

Please sign in to comment.