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(