Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New option: acceptedMethods, to allow for the middleware to process and respond to other methods other than just GET #320

Closed
1 of 2 tasks
ferdinando-ferreira opened this issue Aug 20, 2018 · 1 comment

Comments

@ferdinando-ferreira
Copy link
Contributor

  • Operating System: Windows
  • Node Version: 8.9.4
  • NPM Version: 6.4.0
  • webpack version: 4.16.5
  • webpack-dev-middleware Version: 3.1.3
  • This is a feature request
  • This is a bug

What is the motivation and/or use-case for the feature?

It would be useful to be able to signal to the middleware that, instead of only GET, it should process other HTTP request methods (like POST, PUT and so forth). Below is an example of how, from the webpack.config, it could be possible to add an option to this middleware (along with other parts of the chain) to allow for just that.

Code

  serve: {
    hotClient: { host:  { client: '*', server: '0.0.0.0' } },
    host: '0.0.0.0',
    devMiddleware: {
      publicPath: ProjectConfig.getOutput(target).publicPath,
      acceptedMethods: ['GET', 'POST']
    },
    add: (app, middleware, options) => {
      const historyOptions = {};
      historyOptions.logger = console.log.bind(console);
      historyOptions.acceptedMethods = ['GET', 'POST'];
      app.use(convert(history(historyOptions)));
    }
  },

#319 contains the minimal set of code necessary to implement such an option in a backward compatible manner, along with tests for its correcly behaviour and updates on the documentation. It is also tested in a real world application and works as intended.

Best regards

@alexander-akait
Copy link
Member

Solved 504171a

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants