aws / aws-lambda-go

Libraries, samples and tools to help Go developers develop AWS Lambda functions.
Apache License 2.0
3.62k stars 550 forks source link

Small improvement in APIGatewayWebsocketProxyRequestContext.Authorizer #558

Closed ParkChangSun closed 5 months ago

ParkChangSun commented 5 months ago

I'm developing a lambda application with websocket api. I saw a difference between REST api and WebSocket api in event context struct, and both can use Lambda REQUEST authorizer function

APIGatewayCustomAuthorizerResponse.Context and APIGatewayProxyRequestContext.Authorizer are both map[string]interface{} type, but APIGatewayWebsocketProxyRequestContext.Authorizer is interface{} type.

Can it be changed to map[string]interface{}? So that I can do:

userId := req.RequestContext.Authorizer["UserId"].(string)

instead of:

userId := req.RequestContext.Authorizer.(map[string]interface{})["UserId"].(string)

Or is there any reason that it is interface{}?