Open seanvm opened 1 year ago
Bumping this, currently running serverless offline with go and and api gateway v2 does not work and produces the following error :
panic: interface conversion: interface {} is func(context.Context, events.APIGatewayV2HTTPRequest) (events.APIGatewayV2HTTPResponse, error), not func(context.Context, events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error)
Bug Report
Current Behavior
When mounting the handler code directly (e.g. not passing
--useDocker
) the app will fail to run if the handler function signature is not one of the expectedApiGateway
request structs.It looks like support was added last year by @icarus-sullivan via #1320 using https://github.com/icarus-sullivan/mock-lambda for wrapping the
lambda.Start
function. The version included in serverless-offline seems to have a strict requirement for what the handler function signature should look like:However, a lambda function may have a custom request or response type - this is particularly true if the Lambda function is being used with Appsync. As a result the app will fail to run due to an interface conversion error:
Sample Code
Example from aws: https://docs.aws.amazon.com/lambda/latest/dg/golang-handler.html
Expected behavior/code
serverless-offline should support handlers with custom request/response types
Environment
serverless
version: v3.28.1serverless-offline
version: 12.0.4Additional context/Screenshots