File tree Expand file tree Collapse file tree 3 files changed +40
-3
lines changed Expand file tree Collapse file tree 3 files changed +40
-3
lines changed Original file line number Diff line number Diff line change @@ -168,9 +168,10 @@ functions:
168168` ` `
169169- src
170170 - testing
171- - handler.go -> package testing
171+ - handler.go -> package main inside "src/ testing" directory
172172 - second
173- - handler.go -> package second
173+ - handler.go -> package main inside "src/second" directory
174+ - handler.go -> package main at the root of the project
174175- serverless.yml
175176` ` `
176177Your serverless.yml `functions` should look something like this :
@@ -179,6 +180,8 @@ provider:
179180 # ...
180181 runtime: golang
181182functions:
183+ root:
184+ handler: "."
182185 testing:
183186 handler: src/testing
184187 second:
Original file line number Diff line number Diff line change 1+ package main
2+
3+ import (
4+ "encoding/json"
5+
6+ "github.com/scaleway/scaleway-functions-go/events"
7+ "github.com/scaleway/scaleway-functions-go/lambda"
8+ )
9+
10+ // Handler - Handle event
11+ func Handler (req events.APIGatewayProxyRequest ) (events.APIGatewayProxyResponse , error ) {
12+ response := map [string ]interface {}{
13+ "message" : "My Custom Package" ,
14+ }
15+
16+ responseB , err := json .Marshal (response )
17+ if err != nil {
18+ return events.APIGatewayProxyResponse {}, err
19+ }
20+
21+ return events.APIGatewayProxyResponse {
22+ Body : string (responseB ),
23+ StatusCode : 200 ,
24+ }, nil
25+ }
26+
27+ func main () {
28+ lambda .Start (Handler )
29+ }
Original file line number Diff line number Diff line change @@ -22,7 +22,12 @@ package:
2222
2323functions :
2424 first :
25- handler : function
25+ # If handler is at the root of your serverless project
26+ handler : " ."
2627 # Local environment variables - used only in given function
2728 env :
2829 local : local
30+
31+ mypackage :
32+ # if your handler is in a custom package
33+ handler : mypackage
You can’t perform that action at this time.
0 commit comments