ProfilerPlugin.php 729 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. declare(strict_types = 1);
  3. /**
  4. * SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCA\DAV\Profiler;
  8. use OCP\IRequest;
  9. use Sabre\DAV\Server;
  10. use Sabre\HTTP\RequestInterface;
  11. use Sabre\HTTP\ResponseInterface;
  12. class ProfilerPlugin extends \Sabre\DAV\ServerPlugin {
  13. public function __construct(
  14. private IRequest $request,
  15. ) {
  16. }
  17. /** @return void */
  18. public function initialize(Server $server) {
  19. $server->on('afterMethod:*', [$this, 'afterMethod']);
  20. }
  21. /** @return void */
  22. public function afterMethod(RequestInterface $request, ResponseInterface $response) {
  23. $response->addHeader('X-Debug-Token', $this->request->getId());
  24. }
  25. }