on('beforeMethod:*', [$this, 'beforeMethod']); } /** * Add the request id as a header in the response * * @param RequestInterface $request request * @param ResponseInterface $response response */ public function beforeMethod(RequestInterface $request, ResponseInterface $response): void { if ($user = $this->userSession->getUser()) { $response->setHeader('X-User-Id', $user->getUID()); } } }