Hacker News new | ask | show | jobs
by ilaksh 2313 days ago
I'm sorry but why can't you just call a few functions in your normal handler and then just return the normal type of object that Lambda wants?

This all seems to be pretty useless indirection to me.

1 comments

@ilaksh the middleware pattern is a common pattern for many large frameworks like ExpressJS and Ruby on Rails. It allows you to cleanly handle the request and response cycle. From a code maintenance perspective, using a well-established pattern that keeps your codebase module and extensible is desired.

If you have one or two lambda functions, then definitely this may be overkill, like you said just call a few functions. But as your system matures and grows, these few functions become a few modules, then your few modules become libraries, so on and so forth. You might want to consider this pattern before it's unclear what exactly is interacting with your requests and responses and in what order.