Skip to content
Snippets Groups Projects
Commit 9724fbfa authored by Mateu Aguiló Bosch's avatar Mateu Aguiló Bosch Committed by Mateu Aguiló Bosch
Browse files

Issue #2979793 by e0ipso: Support GET requests to enable Page Cache

parent 7c7f287f
No related branches found
No related tags found
No related merge requests found
......@@ -2,7 +2,7 @@ jsonrpc.handler:
path: '/jsonrpc'
defaults:
_controller: '\Drupal\jsonrpc\Controller\HttpController::resolve'
methods: [POST]
methods: [POST, GET]
requirements:
_permission: 'use jsonrpc services'
options:
......
......@@ -101,7 +101,12 @@ class HttpController extends ControllerBase {
protected function getRpcRequests(Request $http_request) {
$version = $this->handler->supportedVersion();
try {
$content = Json::decode($http_request->getContent(FALSE));
if ($http_request->getMethod() === Request::METHOD_POST) {
$content = Json::decode($http_request->getContent(FALSE));
}
else if ($http_request->getMethod() === Request::METHOD_GET) {
$content = Json::decode($http_request->query->get('query'));
}
$context = new Context([
RpcRequestFactory::REQUEST_VERSION_KEY => $version,
]);
......
......@@ -3,12 +3,12 @@
namespace Drupal\jsonrpc\Object;
use Drupal\Core\Cache\CacheableDependencyInterface;
use Drupal\Core\Cache\CacheableDependencyTrait;
use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\Cache\RefinableCacheableDependencyTrait;
class Response implements CacheableDependencyInterface {
use CacheableDependencyTrait;
use RefinableCacheableDependencyTrait;
/**
* The JSON-RPC version.
......@@ -64,7 +64,6 @@ class Response implements CacheableDependencyInterface {
$this->id = $id;
if (!is_null($result)) {
$this->result = $result;
$this->setCacheability(CacheableMetadata::createFromObject($result));
}
else {
$this->error = $error;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment