Lambda Middleware Study

Manually (Functional Programming way)

There is an example here:

https://startup-cto.net/simplify-aws-lambda-functions-with-middleware/

Basically use functional programming approach, write high-order functions

Pro:

  • Not forced to use anything unnecessary

  • Has full control

Con:

  • Need more time to write the middle ware - cannot just fetch ready middleware and use

  • Quality of hand-written middleware may not reach to maturity (security) of available solutions

In case of building own middleware, each middleware can be built as (https://dbartholomae.github.io/lambda-middleware/):

(options) => (handler) => (event, context) => Response

Lambda-middleware

https://dbartholomae.github.io/lambda-middleware/

It just uses high-order function and compose to do the work.