Skip to content

Commit 064a1bd

Browse files
committed
Http V2 route params update
Worker Changes to get route parameters of http invocation request from invocation request "route_params" attributes after host made update in Azure/azure-functions-host#9997. TODO: Update lc test after lc image released with host version containing the change.
1 parent 5299308 commit 064a1bd

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

azure_functions_worker/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
SHARED_MEMORY_DATA_TRANSFER = "SharedMemoryDataTransfer"
1212
FUNCTION_DATA_CACHE = "FunctionDataCache"
1313
HTTP_URI = "HttpUri"
14-
14+
REQUIRES_ROUTE_PARAMETERS = "RequiresRouteParameters"
1515
# When this capability is enabled, logs are not piped back to the
1616
# host from the worker. Logs will directly go to where the user has
1717
# configured them to go. This is to ensure that the logs are not

azure_functions_worker/dispatcher.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232
PYTHON_LANGUAGE_RUNTIME, PYTHON_ENABLE_INIT_INDEXING,
3333
METADATA_PROPERTIES_WORKER_INDEXED,
3434
PYTHON_ENABLE_OPENTELEMETRY,
35-
PYTHON_ENABLE_OPENTELEMETRY_DEFAULT)
35+
PYTHON_ENABLE_OPENTELEMETRY_DEFAULT,
36+
REQUIRES_ROUTE_PARAMETERS)
3637
from .extension import ExtensionManager
3738
from .http_v2 import http_coordinator, initialize_http_server, HttpV2Registry, \
3839
sync_http_request, HttpServerInitError
@@ -346,6 +347,7 @@ async def _handle__worker_init_request(self, request):
346347
if HttpV2Registry.http_v2_enabled():
347348
capabilities[constants.HTTP_URI] = \
348349
initialize_http_server(self._host)
350+
capabilities[REQUIRES_ROUTE_PARAMETERS] = _TRUE
349351

350352
except HttpServerInitError:
351353
raise
@@ -578,8 +580,10 @@ async def _handle__invocation_request(self, request):
578580
http_request = await http_coordinator.get_http_request_async(
579581
invocation_id)
580582

581-
await sync_http_request(http_request, invoc_request)
582-
args[fi.trigger_metadata.get('param_name')] = http_request
583+
trigger_arg_name = fi.trigger_metadata.get('param_name')
584+
func_http_request = args[trigger_arg_name]
585+
await sync_http_request(http_request, func_http_request)
586+
args[trigger_arg_name] = http_request
583587

584588
fi_context = self._get_context(invoc_request, fi.name,
585589
fi.directory)
@@ -730,6 +734,7 @@ async def _handle__function_environment_reload_request(self, request):
730734
if HttpV2Registry.http_v2_enabled():
731735
capabilities[constants.HTTP_URI] = \
732736
initialize_http_server(self._host)
737+
capabilities[REQUIRES_ROUTE_PARAMETERS] = _TRUE
733738
except HttpServerInitError:
734739
raise
735740
except Exception as ex:

azure_functions_worker/http_v2.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -243,14 +243,11 @@ async def catch_all(request: request_type): # type: ignore
243243
from e
244244

245245

246-
async def sync_http_request(http_request, invoc_request):
246+
async def sync_http_request(http_request, func_http_request):
247247
# Sync http request route params from invoc_request to http_request
248-
route_params = {key: item.string for key, item
249-
in invoc_request.trigger_metadata.items()
250-
if key not in ['Headers', 'Query']}
251248
(HttpV2Registry.ext_base().RequestTrackerMeta
252249
.get_synchronizer()
253-
.sync_route_params(http_request, route_params))
250+
.sync_route_params(http_request, func_http_request.route_params))
254251

255252

256253
class HttpV2Registry:

0 commit comments

Comments
 (0)