Skip to content

Commit

Permalink
Fix runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
dnys1 committed Mar 9, 2024
1 parent b1a3bcd commit b17a7ed
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions packages/celest/lib/src/runtime/serve.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,20 @@ abstract base class CloudFunctionTarget {
init();
}

static const _contextHeaderPrefix = 'X-Celest-Context-';
static final _contextHeaderMatcher = RegExp(
_contextHeaderPrefix,
caseSensitive: false,
);

Future<Response> _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(
Expand Down

0 comments on commit b17a7ed

Please sign in to comment.