I'm using literally the example function from the Go docs:
package main
import (
"context"
"fmt"
"github.com/aws/aws-lambda-go/lambda"
)
type MyEvent struct {
Name string `json:"name"`
}
func HandleRequest(ctx context.Context, name MyEvent) (string, error) {
return fmt.Sprintf("Hello %s!", name.Name), nil
}
func main() {
lambda.Start(HandleRequest)
}
If I use the test event console and input { "name": "John" }
it works fine.
But if I go to Add Triggers, click API Gateway, then click Create a new API, set Security to Open, leave everything else default, then click Add then Save.
If I see the URL it lists at the bottom as "API endpoint:" and click it, I get "Internal server error".
If I do curl -XPOST -d "{ \"name\": \"Paul\" }" https://AWS-URL-ENDPOINT/amazonaws.com/default/mytestfunction
I get "Internal server error".
What am I doing wrong?