From 73f18bcd3a754e8a59100dd165d048a749aab1fe Mon Sep 17 00:00:00 2001 From: tjpcc Date: Fri, 15 Sep 2023 16:20:03 -0600 Subject: include the root route in pathtree.Routes() --- internal/pathtree.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'internal') diff --git a/internal/pathtree.go b/internal/pathtree.go index 3861c8e..25d000d 100644 --- a/internal/pathtree.go +++ b/internal/pathtree.go @@ -38,7 +38,11 @@ type Route[V any] struct { } func (pt PathTree[V]) Routes() []Route[V] { - return pt.tree.routes() + routes := pt.tree.routes() + if pt.root != nil { + routes = append([]Route[V]{{Pattern: "", Value: *pt.root}}, routes...) + } + return routes } // pattern segment which must be a specific string ("/users/"). -- cgit v1.2.3