Closed sardikB closed 1 year ago
I have started the application locally and in a function getUser i want to add a middleware and i have added it like shown below
getUsers: handler: ORM.lambdas.createUser.getUsers events: - http: path: /getUser/{id} method: get cors: true middleware: pre: - ORM.lambdas.createUser.middleware2 "ORM.lambdas.createUser.middleware2" this is the path of the middleware function but middleware does not get invoked here is the whole yml file org: sardik app: serverless-auth-mongo service: Auth-MongoDB frameworkVersion: '3' plugins: - serverless-python-requirements - serverless-offline - serverless-middleware custom: pythonRequirements: dockerizePip: false serverless-offline: httpPort: 4000 middleware: pre: - ORM.lambdas.createUser.middleware2 provider: name: aws runtime: python3.9 environment: JWT_ALGORITHM: 'HS256' JWT_SECRET: 'secret' functions: hello: handler: handler.hello events: - httpApi: path: / method: get createUser: handler: ORM.lambdas.createUser.createUser events: - http: path: /createUser method: post cors: true login: handler: ORM.lambdas.createUser.login events: - http: path: /login method: post cors: true getUsers: handler: ORM.lambdas.createUser.getUsers events: - http: path: /getUser/{id} method: get cors: true middleware: pre: - ORM.lambdas.createUser.middleware2 updateUsers: handler: ORM.lambdas.createUser.updateUsers events: - http: path: /updateUser/{id} method: put cors: true deleteUsers: handler: ORM.lambdas.createUser.deleteUsers events: - http: path: /deleteUsers/{id} method: delete cors: true serverless middleware version => ^3.1.0
Hi, I think that you need to add the middleware plugin before the offline plugin so it works.
I have started the application locally and in a function getUser i want to add a middleware and i have added it like shown below