juanjoDiaz / serverless-middleware

Serverless plugin to allow middleware handlers configured directly in serverless.yaml
MIT License
18 stars 11 forks source link

Exclude/include rule for pre an pos keys #6

Closed sebastianDejoy closed 3 years ago

sebastianDejoy commented 5 years ago

Hi @juanjoDiaz , thanks for the support the last time. Now, I have to set a middleware for most of my lambda functions and i would like to know if the plugin supports a standard way to introduce a blacklist for excluding lambda functions in pre and pos, something like this:

custom:
  middleware:
    pre:
      - auth.authenticate
      - auth.authorize
      exclude:
       - myExcludedFunction.handler
    pos:
      - catch: utils.handlerError
juanjoDiaz commented 5 years ago

Hi @sebastianDejoy ,

Can you elaborate a bit more on the use case? What would excluding a handler do?

The idea of this plugin is to run the handlers sequentially. You could even have the same handler multiple times. So I'm a bit unsure of what exclude would do. Why excluding in custom instead of just not adding it anywhere? If there are multiple occurrences of the middleware (I don't know why, but it's technically possible) how would it work?

sebastianDejoy commented 3 years ago

Hey @juanjoDiaz, thanks for your help. In the end, i hadn't to use "blacklists" and i was able to figure out a solution. I'll close the thread.