1
0

ProfilerPlugin.php 773 B

1234567891011121314151617181920212223242526272829303132
  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. private IRequest $request;
  14. public function __construct(IRequest $request) {
  15. $this->request = $request;
  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. }