summaryrefslogtreecommitdiff
path: root/router.go
diff options
context:
space:
mode:
Diffstat (limited to 'router.go')
-rw-r--r--router.go7
1 files changed, 5 insertions, 2 deletions
diff --git a/router.go b/router.go
index 71ef74c..65f8568 100644
--- a/router.go
+++ b/router.go
@@ -72,13 +72,16 @@ func (r Router) Match(request *Request) (Handler, map[string]string) {
// mounted sub-router should have patterns which only include the portion of the path
// after whatever was matched by the prefix pattern.
//
-// The root pattern ("/") in the sub-router will become a route which must end with a
-// forward slash.
+// The root pattern ("/") in the sub-router will become a route which may or may not
+// end with a forward slash.
func (r *Router) Mount(prefix string, subrouter *Router) {
prefix = strings.TrimSuffix(prefix, "/")
for _, subroute := range subrouter.tree.Routes() {
r.Route(prefix+"/"+subroute.Pattern, subroute.Value)
+ if subroute.Pattern == "" {
+ r.Route(prefix, subroute.Value)
+ }
}
}