From b17a7ede58d15e50ff458b48caa8a07274c78a98 Mon Sep 17 00:00:00 2001 From: Dillon Nys Date: Fri, 8 Mar 2024 18:27:20 -0800 Subject: [PATCH] Fix runtime --- packages/celest/lib/src/runtime/serve.dart | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/celest/lib/src/runtime/serve.dart b/packages/celest/lib/src/runtime/serve.dart index b13e24b4..8b84b29e 100644 --- a/packages/celest/lib/src/runtime/serve.dart +++ b/packages/celest/lib/src/runtime/serve.dart @@ -57,14 +57,20 @@ abstract base class CloudFunctionTarget { init(); } + static const _contextHeaderPrefix = 'X-Celest-Context-'; + static final _contextHeaderMatcher = RegExp( + _contextHeaderPrefix, + caseSensitive: false, + ); + Future _handler(Request request) async { final bodyJson = await request.decodeJson(); - const contextHeaderPrefix = 'X-Celest-Context-'; final response = await runZoned( () => handle({ for (final MapEntry(:key, :value) in request.headers.entries) - if (key.startsWith(contextHeaderPrefix)) - key.substring(contextHeaderPrefix.length): value, + if (key.startsWith(_contextHeaderMatcher)) + '\$${key.substring(_contextHeaderPrefix.length).toLowerCase()}': + value, ...bodyJson, }), zoneSpecification: ZoneSpecification(