gorilla/mux — pull request #25 by johnnadratowski (2013-06-05 23:15:37+00:00)
Title: Optional Clearing Context

I am submitting this pull request for optionally turning off clearing of the request context variables for a router.

I am finding that while working with mux, I may want to dispatch all of my calls through a single top-level handler. When this happens, I would like to handle some things, such as errors, after the internal mux router ServeHTTP method. For example, I might do something like this:

http.HandleFunc("/", func (w http.ResponseWriter, r *http.Request) {
// Set up context variables for request
// Defer Clear

router.ServeHTTP(w, r)

// HERE - I want to work with the context variables
})

So, I am submitting this pull request. I hope find it adds value to the project and accept it. I've added a new test as well, in mux_test.go.