awslabs / aws-lambda-go-api-proxy

lambda-go-api-proxy makes it easy to port APIs written with Go frameworks such as Gin (https://gin-gonic.github.io/gin/ ) to AWS Lambda and Amazon API Gateway.
Apache License 2.0
1.03k stars 198 forks source link

error using handlerfunc adapter: handler kind ptr is not func: errorString #120

Closed caevv closed 2 years ago

caevv commented 2 years ago

Using handlerfuncadapter

handler kind ptr is not func: errorString
func Handler(res http.ResponseWriter, req *http.Request) {
    return nil
}

func main() {
    adapter := handlerfuncadapter.New(Handler)
    lambda.Start(adapter)
}
caevv commented 2 years ago

Silly mistake, fixed:

func Handler(res http.ResponseWriter, req *http.Request) {
    return nil
}

func main() {
    adapter := handlerfuncadapter.New(Handler)

    lambda.Start(func(ctx context.Context, req events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {
        return adapter.ProxyWithContext(ctx, req)
    })
}