Add BuildVarsFunc to allow modifying route variables before generating a route's URL

This commit is contained in:
Quinn Slack
2014-04-17 01:17:15 -07:00
parent 270c42505a
commit cef3b0cd6d
4 changed files with 70 additions and 10 deletions

View File

@@ -133,11 +133,7 @@ func (r *routeRegexp) Match(req *http.Request, match *RouteMatch) bool {
}
// url builds a URL part using the given values.
func (r *routeRegexp) url(pairs ...string) (string, error) {
values, err := mapFromPairs(pairs...)
if err != nil {
return "", err
}
func (r *routeRegexp) url(values map[string]string) (string, error) {
urlValues := make([]interface{}, len(r.varsN))
for k, v := range r.varsN {
value, ok := values[v]