Multiple handlers per function

Hello,

I would like to know if it’s possible to declare multiple handlers per function. I’m looking to follow “Services Pattern” from this guide: https://serverless.com/blog/serverless-architecture-code-patterns/ but I would like to not manage the routing in the lambda but directly through API Gateway using multiple handlers per Lambda

Best,
Jean

AWS only allows you to define one handler per Lambda function. To implement the services pattern you need to implement a router inside your handler. If you want to see how I’m doing it I’ve written a blog post about Routing API Gateway Traffic Through One Lamda Function with example code.

2 Likes

Thanks for your help! That’s what we need!

It seems that serverless no longer supports duplicate event types in a single function. I implemented your code and got an error related to duplicate -http events. Is there an update to this approach or did I miss something?