This repository was archived by the owner on Dec 11, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +43
-3
lines changed
Expand file tree Collapse file tree 1 file changed +43
-3
lines changed Original file line number Diff line number Diff line change @@ -56,13 +56,53 @@ curl http://node43-test.default.dev.triggermesh.io
5656{"statusCode":200,"headers":{"Content-Type":"text/html"},"body":"\n <html>\n <style>\n h1 { color: #73757d; }\n </style>\n <body>\n <h1>Landing Page</h1>\n <p>Hey Unknown!</p>\n </body>\n </html>"}
5757```
5858
59+ ### Node 10 with ` asnc ` handler
60+
61+ 1 . Prepare function code
62+
63+ ```
64+ mkdir example-lambda-nodejs
65+ cd example-lambda-nodejs
66+ cat > handler.js <<EOF
67+ async function justWait() {
68+ return new Promise((resolve, reject) => setTimeout(resolve, 100));
69+ }
70+
71+ module.exports.sayHelloAsync = async (event) => {
72+ await justWait();
73+ return {hello: event.name};
74+ };
75+ EOF
76+
77+ node -e "require('./handler').sayHelloAsync({}).then(h => console.log(h))"
78+ ```
79+
80+ 2 . Install node-10.x buildtemplate
81+
82+ ```
83+ tm deploy buildtemplate -f https://raw.githubusercontent.com/triggermesh/knative-lambda-runtime/master/node-10.x/buildtemplate.yaml
84+ ```
85+
86+ 3 . Deploy function
87+
88+ ```
89+ tm deploy service node-lambda -f . --build-template knative-node10-runtime --build-argument HANDLER=handler.sayHelloAsync --wait
90+ ```
91+
92+ Done:
93+
94+ ```
95+ curl http://node-lambda.default.dev.triggermesh.io --data '{"name": "Foo"}'
96+ # {"hello":"Foo"}
97+ ```
98+
5999### Go
60100
611011 . Prepare function code
62102
63103```
64- mkdir lambda
65- cd lambda
104+ mkdir example- lambda-go
105+ cd example- lambda-go
66106cat > main.go <<EOF
67107package main
68108
@@ -73,7 +113,7 @@ import (
73113)
74114
75115type MyEvent struct {
76- Name string `json:"name"`
116+ Name string \ `json:"name"\ `
77117}
78118
79119func HandleRequest(ctx context.Context, name MyEvent) (string, error) {
You can’t perform that action at this time.
0 commit comments