mirror of
https://github.com/appwrite/appwrite.git
synced 2026-11-18 20:36:03 +00:00
Use injected 'params' local instead of getPathValues reconstruction
The http server exposes the route's path values as an injectable 'params' local, so inject it directly rather than rebuilding them via Router::preparePath() + Route::getPathValues(). Query/body params and declared defaults are still merged in to reproduce the full resolved param set (path values take precedence), matching prior getParamsValues() behaviour. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
da8ff0f99c
commit
ad7a76abbb
1 file changed
+6
-5
@@ -38,7 +38,6 @@ use Utopia\Database\Validator\Authorization\Input;
|
||||
use Utopia\Database\Validator\Roles;
|
||||
use Utopia\Http\Http;
|
||||
use Utopia\Http\Route;
|
||||
use Utopia\Http\Router;
|
||||
use Utopia\Span\Span;
|
||||
use Utopia\System\System;
|
||||
use Utopia\Telemetry\Adapter as Telemetry;
|
||||
@@ -787,6 +786,7 @@ Http::shutdown()
|
||||
Http::shutdown()
|
||||
->groups(['api'])
|
||||
->inject('route')
|
||||
->inject('params')
|
||||
->inject('request')
|
||||
->inject('response')
|
||||
->inject('project')
|
||||
@@ -806,7 +806,7 @@ Http::shutdown()
|
||||
->inject('bus')
|
||||
->inject('apiKey')
|
||||
->inject('mode')
|
||||
->action(function (Route $route, Request $request, Response $response, Document $project, User $user, Event $queueForEvents, AuditContext $auditContext, Audit $publisherForAudits, Context $usage, UsagePublisher $publisherForUsage, FunctionPublisher $publisherForFunctions, Event $queueForWebhooks, Realtime $queueForRealtime, Database $dbForProject, Authorization $authorization, callable $timelimit, EventProcessor $eventProcessor, Bus $bus, ?Key $apiKey, string $mode) use ($parseLabel) {
|
||||
->action(function (Route $route, array $params, Request $request, Response $response, Document $project, User $user, Event $queueForEvents, AuditContext $auditContext, Audit $publisherForAudits, Context $usage, UsagePublisher $publisherForUsage, FunctionPublisher $publisherForFunctions, Event $queueForWebhooks, Realtime $queueForRealtime, Database $dbForProject, Authorization $authorization, callable $timelimit, EventProcessor $eventProcessor, Bus $bus, ?Key $apiKey, string $mode) use ($parseLabel) {
|
||||
|
||||
$responsePayload = $response->getPayload();
|
||||
|
||||
@@ -863,13 +863,14 @@ Http::shutdown()
|
||||
}
|
||||
}
|
||||
|
||||
$preparedPath = Router::preparePath($route->getMatchedPath());
|
||||
$pathValues = $route->getPathValues($request, $preparedPath[0]);
|
||||
// $params holds the URL path values (injected from the route match);
|
||||
// merge in query/body params and declared defaults to reproduce the
|
||||
// full resolved param set, with path values taking precedence.
|
||||
$reqParams = $request->getParams();
|
||||
|
||||
$requestParams = [];
|
||||
foreach ($route->getParams() as $key => $param) {
|
||||
$requestParams[$key] = $pathValues[$key] ?? $reqParams[$key] ?? $param['default'];
|
||||
$requestParams[$key] = $params[$key] ?? $reqParams[$key] ?? $param['default'];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user