Skip to content

Commit e412491

Browse files
committed
Merge branch 'master' of github.com:serverless/examples
2 parents a9c9d48 + ac5c75e commit e412491

File tree

127 files changed

+21657
-506
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

127 files changed

+21657
-506
lines changed

README.md

Lines changed: 18 additions & 2 deletions
Large diffs are not rendered by default.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Gopkg.toml example
2+
#
3+
# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md
4+
# for detailed Gopkg.toml documentation.
5+
#
6+
# required = ["github.com/user/thing/cmd/thing"]
7+
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
8+
#
9+
# [[constraint]]
10+
# name = "github.com/user/project"
11+
# version = "1.0.0"
12+
#
13+
# [[constraint]]
14+
# name = "github.com/user/project2"
15+
# branch = "dev"
16+
# source = "github.com/myfork/project2"
17+
#
18+
# [[override]]
19+
# name = "github.com/x/y"
20+
# version = "2.4.0"
21+
22+
23+
[[constraint]]
24+
name = "github.com/aws/aws-lambda-go"
25+
version = "1.x"
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
build:
2+
dep ensure -v
3+
env GOOS=linux go build -ldflags="-s -w" -o bin/hello hello/main.go
4+
env GOOS=linux go build -ldflags="-s -w" -o bin/world world/main.go
5+
6+
.PHONY: clean
7+
clean:
8+
rm -rf ./bin ./vendor Gopkg.lock
9+
10+
.PHONY: deploy
11+
deploy: clean build
12+
sls deploy --verbose
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!--
2+
title: TODO
3+
description: This example demonstrates how to setup a simple HTTP endpoint in Go.
4+
layout: Doc
5+
framework: v1
6+
platform: AWS
7+
language: Go
8+
authorLink: 'https://github.com/sebito91'
9+
authorName: 'Sebastian Borza'
10+
authorAvatar: 'https://avatars0.githubusercontent.com/u/3159454?v=4&s=140'
11+
-->
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package main
2+
3+
import (
4+
"bytes"
5+
"context"
6+
"encoding/json"
7+
8+
"github.com/aws/aws-lambda-go/events"
9+
"github.com/aws/aws-lambda-go/lambda"
10+
)
11+
12+
// Response is of type APIGatewayProxyResponse since we're leveraging the
13+
// AWS Lambda Proxy Request functionality (default behavior)
14+
//
15+
// https://serverless.com/framework/docs/providers/aws/events/apigateway/#lambda-proxy-integration
16+
type Response events.APIGatewayProxyResponse
17+
18+
// Handler is our lambda handler invoked by the `lambda.Start` function call
19+
func Handler(ctx context.Context) (Response, error) {
20+
var buf bytes.Buffer
21+
22+
body, err := json.Marshal(map[string]interface{}{
23+
"message": "Go Serverless v1.0! Your function executed successfully!",
24+
})
25+
if err != nil {
26+
return Response{StatusCode: 404}, err
27+
}
28+
json.HTMLEscape(&buf, body)
29+
30+
resp := Response{
31+
StatusCode: 200,
32+
IsBase64Encoded: false,
33+
Body: buf.String(),
34+
Headers: map[string]string{
35+
"Content-Type": "application/json",
36+
"X-MyCompany-Func-Reply": "hello-handler",
37+
},
38+
}
39+
40+
return resp, nil
41+
}
42+
43+
func main() {
44+
lambda.Start(Handler)
45+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"name": "aws-golang-simple-http-endpoint",
3+
"version": "0.0.1",
4+
"description": "Example demonstrates how to setup a simple HTTP GET endpoint with golang",
5+
"author": "Sebastian Borza <sebito91@gmail.com>",
6+
"license": "MIT"
7+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
service: aws-golang-simple-http-endpoint
2+
3+
frameworkVersion: ">=1.28.0 <2.0.0"
4+
5+
provider:
6+
name: aws
7+
runtime: go1.x
8+
9+
functions:
10+
hello:
11+
handler: bin/hello
12+
events:
13+
- http:
14+
path: hello
15+
method: get
16+
world:
17+
handler: bin/world
18+
events:
19+
- http:
20+
path: world
21+
method: get
22+
23+
package:
24+
exclude:
25+
- ./**
26+
include:
27+
- ./bin/**
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package main
2+
3+
import (
4+
"bytes"
5+
"context"
6+
"encoding/json"
7+
8+
"github.com/aws/aws-lambda-go/events"
9+
"github.com/aws/aws-lambda-go/lambda"
10+
)
11+
12+
// Response is of type APIGatewayProxyResponse since we're leveraging the
13+
// AWS Lambda Proxy Request functionality (default behavior)
14+
//
15+
// https://serverless.com/framework/docs/providers/aws/events/apigateway/#lambda-proxy-integration
16+
type Response events.APIGatewayProxyResponse
17+
18+
// Handler is our lambda handler invoked by the `lambda.Start` function call
19+
func Handler(ctx context.Context) (Response, error) {
20+
var buf bytes.Buffer
21+
22+
body, err := json.Marshal(map[string]interface{}{
23+
"message": "Okay so your other function also executed successfully!",
24+
})
25+
if err != nil {
26+
return Response{StatusCode: 404}, err
27+
}
28+
json.HTMLEscape(&buf, body)
29+
30+
resp := Response{
31+
StatusCode: 200,
32+
IsBase64Encoded: false,
33+
Body: buf.String(),
34+
Headers: map[string]string{
35+
"Content-Type": "application/json",
36+
"X-MyCompany-Func-Reply": "world-handler",
37+
},
38+
}
39+
40+
return resp, nil
41+
}
42+
43+
func main() {
44+
lambda.Start(Handler)
45+
}

aws-java-simple-http-endpoint/README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
<!--
2-
title: AWS Simple HTTP Endpoint example in Java
3-
description: This example demonstrates how to setup a simple HTTP GET endpoint using Java. Once you ping it, it will reply with the current time.
2+
title: 'AWS Simple HTTP Endpoint example in Java'
3+
description: 'This example demonstrates how to setup a simple HTTP GET endpoint using Java. Once you ping it, it will reply with the current time.'
44
layout: Doc
5+
framework: v1
6+
platform: AWS
7+
language: Java
8+
authorLink: 'https://github.com/DoWhileGeek'
9+
authorName: 'Joeseph Rodrigues'
10+
authorAvatar: 'https://avatars3.githubusercontent.com/u/1767769?v=4&s=140'
511
-->
612
# Simple HTTP Endpoint Example
713

@@ -131,7 +137,7 @@ The expected result should be similar to:
131137
}
132138
--------------------------------------------------------------------
133139
START RequestId: XXXXXXX Version: $LATEST
134-
2017-01-04 23:44:37 <XXXXXXX> INFO com.serverless.Handler:18 - received: {}
140+
2004 23:44:37 <XXXXXXX> INFO com.serverless.Handler:18 - received: {}
135141
END RequestId: XXXXXXX
136142
REPORT RequestId: XXXXXXX Duration: 0.51 ms Billed Duration: 100 ms Memory Size: 1024 MB Max Memory Used: 53 MB
137143
```

aws-multiple-runtime/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!--
2+
title: TODO
3+
description: This example demonstrates how you can run multiple runtimes in AWS Lambda.
4+
layout: Doc
5+
framework: v1
6+
platform: AWS
7+
language: nodeJS
8+
authorLink: 'https://github.com/christophgysin'
9+
authorName: 'Christoph Gysin'
10+
authorAvatar: 'https://avatars0.githubusercontent.com/u/527924?v=4&s=140'
11+
-->

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy