gorilla/mux — pull request #52 by sqs (2014-04-23 18:50:40+00:00)
Title: BuildVarsFunc: modify route variables before building the URL from a route

This PR introduces a new BuildVarsFunc that can be attached to a route. A BuildVarsFunc allows you to intercept and modify the route variable map passed to `.URL` or `.URLPath` or `.URLHost` before generating the URL.

It is useful when you want to be liberal in matching routes but conservative in constructing them. For example, you might want to normalize all blog post URL slugs to be lowercase, but still match uppercase slugs. Without BuildVarsFunc, you would have to ensure that all callers of `.URL{,Path,Host}` lowercased the slug beforehand. With BuildVarsFunc, you can just call `.URL{,Path,Host}` directly without any additional wrapper functions.