3 namespace Drupal\system_test\Controller;
5 use Drupal\Core\Cache\CacheableJsonResponse;
6 use Drupal\Core\Cache\CacheableResponse;
7 use Symfony\Component\HttpFoundation\Request;
10 * Defines a controller to respond the page cache accept header test.
12 class PageCacheAcceptHeaderController {
15 * Processes a request that will vary with Accept header.
17 * @param \Symfony\Component\HttpFoundation\Request $request
18 * The current request object.
22 public function content(Request $request) {
23 if ($request->getRequestFormat() === 'json') {
24 return new CacheableJsonResponse(['content' => 'oh hai this is json']);
27 return new CacheableResponse("<p>oh hai this is html.</p>");