I am experimenting with Go on AWS lambda, and i found that each function requires a binary to be uploaded for execution.
My question is that, is it possible to have a single binary that can have two different Handler
functions, which can be loaded by two different lambda functions.
for example
func Handler(request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {
fmt.Println("Received body in Handler 1: ", request.Body)
return events.APIGatewayProxyResponse{Body: request.Body, StatusCode: 200}, nil
}
func Handler1(request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {
fmt.Println("Received body in Handler 2: ", request.Body)
return events.APIGatewayProxyResponse{Body: request.Body, StatusCode: 200}, nil
}
func EndPoint1() {
lambda.Start(Handler)
}
func EndPoint2() {
lambda.Start(Handler1)
}
and calling the EndPoints
in main
in such a way that it registers both the EndPoints
and the same binary would be uploaded to both the functions MyFunction1
and MyFunction2
.
I understand that having two different binary is good because it reduces the load/size of each function.
But this is just an experimentation.
Thanks in advance :)