algnhsa icon indicating copy to clipboard operation
algnhsa copied to clipboard

Added APIGatewayWebsocketRequest type

Open requaos opened this issue 4 years ago • 5 comments

requaos avatar Nov 12 '20 15:11 requaos

@akrylysov Figured we would want to support this...

requaos avatar Nov 12 '20 15:11 requaos

@akrylysov I am going to mark this as a draft for now. There will need to be some special opts for handling $connect and $disconnect event types for the websocket gateway proxy requests. The events come in really bare, so you basically only have event.requestContext.eventType == "CONNECT" to switch on... but we could switch on event.requestContext.routeKey == $connect depending on how we decide to handle these cases.

In my use case I need to perform a little auth validation and record an access event to the logs, so I define my $connect handler, but if you leave this undefined in your gateway, AWS will handle connect/disconnect events for you.

Since this package aims to fabricate an http request from the event details, the opt, could be more than one, will need to provide httpMethod and path for a given eventType/routeKey.

If you have any opinions or feedback, please let me know.

requaos avatar Nov 12 '20 23:11 requaos

I took some liberties, but please let me know if you have change requests.

requaos avatar Nov 16 '20 19:11 requaos

@akrylysov could you review this PR please? It would be very helpful! Thanks

ghost avatar Mar 04 '21 09:03 ghost

Thanks for the PR! Do you mind adding some tests? Take a look at https://github.com/akrylysov/algnhsa/blob/master/adapter_test.go

akrylysov avatar Apr 21 '21 13:04 akrylysov