about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFranck Cuny <franck@lumberjaph.net>2013-05-12 14:06:13 -0700
committerFranck Cuny <franck@lumberjaph.net>2013-05-12 14:06:13 -0700
commitd4eabf891ce67b01a6321a53115a3b360ebfc017 (patch)
treec8248919cc00d46c41c31ac21591de893d1efa4e
parentThe Match type implement an interface. (diff)
downloadpath-router-master.tar.gz
Add GetPath and GetMethod to the Match object master
-rw-r--r--route.go16
-rw-r--r--route_test.go6
2 files changed, 15 insertions, 7 deletions
diff --git a/route.go b/route.go
index 6c41c95..483f4e3 100644
--- a/route.go
+++ b/route.go
@@ -23,10 +23,10 @@ type Route struct {
 }
 
 type Match struct {
-	Path    string
+	path    string
 	Route   Route
 	mapping map[string]string
-	Method  string
+	method  string
 }
 
 var componentIsVariable = regexp.MustCompile("^{[^}]+}$")
@@ -38,6 +38,14 @@ func (self *Match) RouteParams() map[string]string {
 	return self.mapping
 }
 
+func (self *Match) GetPath() string {
+	return self.path
+}
+
+func (self *Match) GetMethod() string {
+	return self.method
+}
+
 // XXX explain this function
 func (self *Route) convertComponentName(name string) string {
 	newName := convertComponent.FindStringSubmatch(name)
@@ -105,9 +113,9 @@ L:
 	}
 
 	return &Match{
-		Path:    strings.Join(components, "/"),
+		path:    strings.Join(components, "/"),
 		Route:   *self,
-		Method:  method,
+		method:  method,
 		mapping: mapping,
 	}
 }
diff --git a/route_test.go b/route_test.go
index dd38e80..339a797 100644
--- a/route_test.go
+++ b/route_test.go
@@ -103,7 +103,7 @@ func TestMatch(t *testing.T) {
 		if m == nil {
 			t.Fatal()
 		} else {
-			fmt.Println(fmt.Sprintf("%s match for %s", p.Path, m.Path))
+			fmt.Println(fmt.Sprintf("%s match for %s", p.Path, m.GetPath()))
 		}
 	}
 }
@@ -140,7 +140,7 @@ func TestMatchOptional(t *testing.T) {
 		if m == nil {
 			t.Fatal()
 		} else {
-			fmt.Println(fmt.Sprintf("%s match for %s", p.Path, m.Path))
+			fmt.Println(fmt.Sprintf("%s match for %s", p.Path, m.GetPath()))
 		}
 	}
 }
@@ -162,7 +162,7 @@ func TestAmbigiousSimple(t *testing.T) {
 	if m == nil {
 		t.Fatal()
 	} else {
-		fmt.Println(fmt.Sprintf("%s match for %s", r.URL.Path, m.Path))
+		fmt.Println(fmt.Sprintf("%s match for %s", r.URL.Path, m.GetPath()))
 	}
 }