Skip to content

Commit

Permalink
net/http: ServeMux handles extended patterns
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
jba committed Sep 13, 2023
1 parent f7f266c commit 545e4f3
Show file tree
Hide file tree
Showing 2 changed files with 268 additions and 151 deletions.
Loading

0 comments on commit 545e4f3

Please sign in to comment.