Skip to content

Commit

Permalink
fix: missing originContext property in http trigger (#799)
Browse files Browse the repository at this point in the history
  • Loading branch information
czy88840616 authored Jan 11, 2021
1 parent 3438e99 commit 5cd96a0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions packages-serverless/serverless-fc-starter/src/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ export class FCRuntime extends ServerlessLightRuntime {
const newRes = new HTTPResponse();

if (isHTTPMode) {
req.getOriginContext = () => {
return context;
}
// http
// const rawBody = 'test';
// req.rawBody = rawBody;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ exports.handler = asyncWrapper(async (...args) => {
runtime = await start();
}
return runtime.asyncEvent(async function (ctx) {
ctx.body = 'Alan';
ctx.body = 'Alan|' + ctx.originContext.requestId;
})(...args);
});
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ describe('/test/index.test.ts', () => {
method: 'GET',
})
);
assert.equal(result.body, 'Alan');
assert.equal(result.body, 'Alan|b1c5100f-819d-c421-3a5e-7782a27d8a33');
await runtime.close();
});

Expand Down

0 comments on commit 5cd96a0

Please sign in to comment.