lmdrouter icon indicating copy to clipboard operation
lmdrouter copied to clipboard

API Gateway v2 support

Open jamestelfer opened this issue 4 years ago • 2 comments

Do you have any thoughts on what you'd expect support for the v2 API gateway events to look like in this library? It's a useful abstraction to have, and v1 works fine for now, but it would be good to support the newer API.

I'd prefer to get your thoughts before just going ahead and putting together a PR.

jamestelfer avatar Feb 04 '21 02:02 jamestelfer

Hi there, sorry for the delay in response.

I just took a quick glance at the V2 event. Sometimes with AWS Lambda events I create an encapsulating struct type that includes all events I want to catch, e.g. something like:

type Event struct {
   *events.APIGatewayProxyRequest
   *events.CloudWatchEvent
}

And then I check which event I got in the code, but this isn't pretty and won't always work if the two event types share attributes.

In this case it might be necessary to have a NewV2Router() function that only works with V2 events, but maybe you have a better idea.

Thanks!

ido50 avatar Feb 15 '21 13:02 ido50

I tried to add some fancy interface to also work with HTTP API, but struggled. I've created a fork that works with v2 only at: https://github.com/shodgson/lmdrouterv2

shodgson avatar Nov 08 '21 09:11 shodgson