diff options
Diffstat (limited to 'router.go')
-rw-r--r-- | router.go | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/router.go b/router.go index e5c8e13..8612ad2 100644 --- a/router.go +++ b/router.go @@ -7,18 +7,18 @@ import ( "strings" ) -type Dispatcher struct { +type Router struct { routes []*Route knownPaths map[string]map[string]bool } -func BuildDispatcher() Dispatcher { - router := Dispatcher{} +func BuildRouter() Router { + router := Router{} router.knownPaths = map[string]map[string]bool{} return router } -func (self *Dispatcher) routeIsKnown(route *Route) bool { +func (self *Router) routeIsKnown(route *Route) bool { if self.knownPaths[route.Path] == nil { self.knownPaths[route.Path] = map[string]bool{} return false @@ -28,7 +28,7 @@ func (self *Dispatcher) routeIsKnown(route *Route) bool { return true } -func (self *Dispatcher) AddRoute(route *Route) error { +func (self *Router) AddRoute(route *Route) error { if self.routeIsKnown(route) == true { return errors.New(fmt.Sprintf("Can't add twice the same route. The route %s with the method %s is already added", route.Path, route.Method)) } @@ -39,7 +39,7 @@ func (self *Dispatcher) AddRoute(route *Route) error { return nil } -func (self *Dispatcher) Match(request *http.Request) (*Match, error) { +func (self *Router) Match(request *http.Request) (*Match, error) { matches := []*Match{} @@ -63,7 +63,7 @@ func (self *Dispatcher) Match(request *http.Request) (*Match, error) { return nil, nil } -func (self *Dispatcher) disambiguateMatches(path string, matches []*Match) (*Match, error) { +func (self *Router) disambiguateMatches(path string, matches []*Match) (*Match, error) { min := -1 found := []*Match{} |