Skip to content
This repository has been archived by the owner on Mar 28, 2022. It is now read-only.

Support array of methods in route variants #139

Closed
javierbrea opened this issue Mar 17, 2021 · 0 comments · Fixed by #147
Closed

Support array of methods in route variants #139

javierbrea opened this issue Mar 17, 2021 · 0 comments · Fixed by #147
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@javierbrea
Copy link
Member

It is desirable to support an array of methods in the route variants definitions. It makes sense for defining middlewares that should be executed in every method, as described in mocks-server/main#140.

Using the middleware example from the documentation, this is how it should look like:

module.exports = [
  {
    id: "add-headers",
    url: "*",
    method: ["GET", "POST", "PUT", "DELETE"],
    variants: [
      {
        id: "enabled",
        response: (req, res, next) => {
          res.set('Content-Type', 'application/json; charset=utf-8');
          next();
        }
      },
      {
        id: "disabled",
        response: (req, res, next) => next()
      }
    ]
  }  
];
@javierbrea javierbrea added the enhancement New feature or request label Mar 17, 2021
@javierbrea javierbrea added this to the v2.1.0 milestone Mar 17, 2021
@javierbrea javierbrea self-assigned this Mar 17, 2021
This was referenced Mar 22, 2021
@javierbrea javierbrea moved this to Done in Backlog May 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant