#Exclude Middleware

3 messages · Page 1 of 1 (latest)

sharp halo
#

I have a middleware which gets applied in /something/:id and I have another controller with same method but the route is /something/somethingElse. The problem is the middleware is getting applied in both of the routes. How can I exclude it?

consumer
      .apply(
        AuthorizeMiddleWareCreator({
          resourceType: permissions.SOMETHING
        })
      )
      .forRoutes({ path: 'something/:id', method: RequestMethod.PUT });
mental cipher
sharp halo
#

Actually I tried that already by doing this. But wasn't working.

    consumer
      .apply(
        AuthorizeMiddleWareCreator({
          resourceType: permissions.SOMETHING
        })
      )
      .exclude({
        path: 'something/somethingElse',
        method: RequestMethod.PUT
      })
      .forRoutes({ path: 'something/:id', method: RequestMethod.PUT });