Skip to content

Commit 545e4f3

Browse files
committed
net/http: ServeMux handles extended patterns
Modify ServeMux to handle patterns with methods and wildcards. Remove the map and list of patterns. Instead patterns are registered and matched using a routing tree. We also reorganize the code around "trailing-slash redirection," the feature whereby a trailing slash is added to a path if it doesn't match an existing one. The existing code checked the map of paths twice, but searching the tree twice would be needlessly expensive. The rewrite searches the tree once, and then again only if a trailing-slash redirection is possible. There are a few omitted features in this CL, indicated with TODOs. Change-Id: Ifaef59f6c8c7b7131dc4a5d0f101cc22887bdc74 Reviewed-on: https://go-review.googlesource.com/c/go/+/528039 Run-TryBot: Jonathan Amsterdam <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Damien Neil <[email protected]>
1 parent f7f266c commit 545e4f3

File tree

2 files changed

+268
-151
lines changed

2 files changed

+268
-151
lines changed

0 commit comments

Comments
 (0)