From 0099eef8c86427f2af29d7a4babecc01374c2aa6 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Mon, 12 May 2025 19:25:52 +1200 Subject: [PATCH] Faster short-path for single method routes --- src/Appwrite/Utopia/Request.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Appwrite/Utopia/Request.php b/src/Appwrite/Utopia/Request.php index 611be4c229..b80950bbb6 100644 --- a/src/Appwrite/Utopia/Request.php +++ b/src/Appwrite/Utopia/Request.php @@ -35,14 +35,20 @@ class Request extends UtopiaRequest } $methods = self::getRoute()->getLabel('sdk', null); - $methods = \is_array($methods) ? $methods : [$methods]; if (empty($methods)) { return $parameters; } - $matched = null; + if (!\is_array($methods)) { + $id = $methods->getNamespace() . '.' . $methods->getMethodName(); + foreach ($this->getFilters() as $filter) { + $parameters = $filter->parse($parameters, $id); + } + return $parameters; + } + $matched = null; foreach ($methods as $method) { /** @var Method|null $method */ if ($method === null) { @@ -60,7 +66,7 @@ class Request extends UtopiaRequest } } - $endpointIdentifier = $matched !== null + $id = $matched !== null ? $matched->getNamespace() . '.' . $matched->getMethodName() : 'unknown.unknown'; @@ -71,7 +77,7 @@ class Request extends UtopiaRequest // Apply filters foreach ($this->getFilters() as $filter) { - $parameters = $filter->parse($parameters, $endpointIdentifier); + $parameters = $filter->parse($parameters, $id); } return $parameters;