New option: acceptedMethods, to allow for the middleware to process and respond to other methods other than just GET #320
Closed
Description
- 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
Metadata
Assignees
Labels
No labels