gruntjs/grunt-contrib-connect — pull request #85 by steve-jansen (2014-02-11 18:31:48+00:00)
Title: Enhancements to `options.middleware`

Hi,

I'm the author of a developer utility called [json-proxy](steve-jansen/json-proxy) and love grunt! I noticed recently my documentation for injecting json-proxy as middleware into grunt-contrib-connect no longer worked properly with Yeoman.io templates.

I realized that users are copying the default middlewares function from [connect.js#L31-45](https://github.com/gruntjs/grunt-contrib-connect/blob/master/tasks/connect.js#L31-45).

This seems really fragile, and awkward for users. See https://github.com/drewzboto/grunt-connect-proxy/issues/29 as an example.

So, I enhanced the `options.middleware` logic to maintain backwards compatibility yet make life easier for extending the default middlewares:
* modified options.middleware to accept an array or a function
* modified the arguments sent to the options.middleware function to include a third argument that is the array of default middlewares

I included passing nodeunit tests and updated the relevant docs.

Enjoy!
Steve