-
Notifications
You must be signed in to change notification settings - Fork 0
/
tmpl-languages.go
117 lines (93 loc) · 1.69 KB
/
tmpl-languages.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
package main
// node.js
const nodeFunction = `
'use strict'
exports.handler = function(event, context) {
let msg = {
statusCode: 200,
body: 'hello world'
}
context.succeed(msg);
};
`
const packageJSON = `
{
"name": "helloworld",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
},
"devDependencies": {
"lambda-local": "^1.6.3"
}
}
`
// python
const pythonFunction = `
import json
def handler(event, context):
dict = { "msg" : "hello world" }
return {
'statusCode': 200,
'body': json.dumps(dict)
}
`
const requirementsFile = `
`
// ruby
const rubyFunction = `
require 'json'
def handler(event:, context:)
msg = {:msg => 'hello world'}
return {
:statusCode => 200,
:body => msg.to_json
}
end
`
const gemFile = `
`
// go
const goFunction = `
package main
import (
"context"
"encoding/json"
"github.com/aws/aws-lambda-go/events"
"github.com/aws/aws-lambda-go/lambda"
)
type Response events.APIGatewayProxyResponse
type helloWorld struct {
Msg string` + "`" + `json:"msg"` + "`" + `
}
func handler(ctx context.Context) (Response, error) {
msg := helloWorld{Msg: "hello world"}
resp, err := json.Marshal(msg)
if err != nil {
return Response{StatusCode: 500}, err
}
gwResp := Response{
StatusCode: 200,
Body: string(resp),
Headers: map[string]string{
"Content-Type": "application/json",
},
}
return gwResp, nil
}
func main() {
lambda.Start(handler)
}
`
const goMod = `
module helloworld
go 1.13
require github.com/aws/aws-lambda-go v1.13.3
`