senchalabs/connect — pull request #696 by JonDum (2012-11-27 04:49:47+00:00)
Title: Add a method to remove middleware

I came across a situation where I needed to remove middleware after the server has started. Alas, there wasn't any method to do this.

My use case consists of allowing the changing, adding, removing of Static directories from persistent user settings. Yes, I could write some fancy request handlers to do this, but why reinvent the wheel when the Static middleware does everything I need perfectly? Making middleware more effective > reinventing the wheel, no?

I didn't really know what to name the function so I went with `unuse()`. Add middleware with `use()`, remove it with `unuse()`.

Also, my preferred method would have been to return an id when you call `use()` so that you can use that to simply remove that specific middleware. That would require some heavy refactoring and would break chaining. Instead, `unuse()` removes all middle of the same type at the same route. I couldn't think of any instances where you would want