about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--dispatcher.go1
-rw-r--r--route.go11
2 files changed, 5 insertions, 7 deletions
diff --git a/dispatcher.go b/dispatcher.go
index 62dee10..3b98b5f 100644
--- a/dispatcher.go
+++ b/dispatcher.go
@@ -37,6 +37,7 @@ func (self *Dispatcher) AddRoute(path string, method string, code func(*Request)
 		self.RouteAccess[path] = &route
 	} else {
 		r.Executors[method] = code
+		r.Methods[method] = true
 	}
 }
 
diff --git a/route.go b/route.go
index 46998c1..9fc86ee 100644
--- a/route.go
+++ b/route.go
@@ -16,6 +16,7 @@ type Route struct {
 	OptionalNamedComponents map[string]bool
 	Length                  int
 	LengthWithoutOptional   int
+	Methods                 map[string]bool
 }
 
 type Match struct {
@@ -36,13 +37,8 @@ func (self *Route) convertComponentName(name string) string {
 }
 
 func (self *Route) Match(method string, components []string) *Match {
-	methodMatch := false
-	for m, _ := range self.Executors {
-		if m == method {
-			methodMatch = true
-		}
-	}
-	if methodMatch == false {
+
+	if self.Methods[method] != true {
 		return nil
 	}
 
@@ -99,6 +95,7 @@ func MakeRoute(path string, method string, code fn) Route {
 		OptionalNamedComponents: optComponents,
 		Length:                  len(components),
 		LengthWithoutOptional:   len(components) - len(optComponents),
+		Methods:                 map[string]bool{method: true},
 	}
 
 	return route