about summary refs log tree commit diff
path: root/route.go
diff options
context:
space:
mode:
Diffstat (limited to 'route.go')
-rw-r--r--route.go14
1 files changed, 6 insertions, 8 deletions
diff --git a/route.go b/route.go
index d84d026..b26ad5a 100644
--- a/route.go
+++ b/route.go
@@ -14,12 +14,12 @@ type Route struct {
 	RequiredNamedComponents map[string]bool
 	OptionalNamedComponents map[string]bool
 	Length                  int
-	LengthWithoutOptional int
+	LengthWithoutOptional   int
 }
 
 type Match struct {
 	Path    string
-	Route   *Route
+	Route   Route
 	Mapping map[string]string
 	Method  string
 }
@@ -29,7 +29,6 @@ var componentsIsOptional = regexp.MustCompile("^?:")
 var namedComponentsRegex = regexp.MustCompile("^:(.*)$")
 
 func (self *Route) Match(request Request) *Match {
-
 	methodMatch := false
 	for m, _ := range self.Executors {
 		if m == request.Method {
@@ -42,6 +41,7 @@ func (self *Route) Match(request Request) *Match {
 
 	components := strings.Split(request.Request.URL.Path, "/")
 
+	//fmt.Println(fmt.Sprintf("components are %s and %s, the lenght is %d, the length without opt is %d and total is %d", components, self.Components, len(components), self.LengthWithoutOptional, self.Length))
 	if len(components) < self.LengthWithoutOptional || len(components) > self.Length {
 		return nil
 	}
@@ -63,14 +63,12 @@ func (self *Route) Match(request Request) *Match {
 		}
 	}
 
-	match := &Match{
+	return &Match{
 		Path:    request.Request.URL.Path,
-		Route:   self,
-		Mapping: mapping,
+		Route:   *self,
 		Method:  request.Method,
+		Mapping: mapping,
 	}
-
-	return match
 }
 
 func (self *Route) Execute(request *Request) (Response, error) {