about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFranck Cuny <franck@lumberjaph.net>2013-05-12 14:01:22 -0700
committerFranck Cuny <franck@lumberjaph.net>2013-05-12 14:01:22 -0700
commit2f0b6720f447d3e4dfad777df015533431939900 (patch)
tree31203d142a778d6f07af76d7a19efab42c08f0af
parentFmt (diff)
downloadpath-router-2f0b6720f447d3e4dfad777df015533431939900.tar.gz
The Match type implement an interface.
The "mapping" field that contains the map of elements in the path is now
private and can be accesed via the RouteParams function.
-rw-r--r--route.go8
1 files changed, 6 insertions, 2 deletions
diff --git a/route.go b/route.go
index 49d627d..6c41c95 100644
--- a/route.go
+++ b/route.go
@@ -25,7 +25,7 @@ type Route struct {
 type Match struct {
 	Path    string
 	Route   Route
-	Mapping map[string]string
+	mapping map[string]string
 	Method  string
 }
 
@@ -34,6 +34,10 @@ var componentsIsOptional = regexp.MustCompile("^\\?{.*}$")
 var namedComponentsRegex = regexp.MustCompile("^{(.*)}$")
 var convertComponent = regexp.MustCompile("^\\??{(.*)}$")
 
+func (self *Match) RouteParams() map[string]string {
+	return self.mapping
+}
+
 // XXX explain this function
 func (self *Route) convertComponentName(name string) string {
 	newName := convertComponent.FindStringSubmatch(name)
@@ -104,7 +108,7 @@ L:
 		Path:    strings.Join(components, "/"),
 		Route:   *self,
 		Method:  method,
-		Mapping: mapping,
+		mapping: mapping,
 	}
 }