Commit 5225da7
expvar: avoid conflict with user-defined "GET /" route.
With the new routing style in go 1.22, declaring
http.Handle("GET /", h)
generates a conflict with route "/debug/vars" declared in the expvar
package. You get an error such as:
panic: pattern "GET /" (registered at ...) conflicts with pattern
"/debug/vars" (registered at ...expvar.go:384): GET / matches fewer
methods than /debug/vars, but has a more general path pattern
This patch prevents that error. Adding GET is correct because no other
method makes sense with /debug/vars.
We preserve the traditional behaviour when GODEBUG=httpmuxgo121=1 is
specified.
Fixes #65723
Change-Id: Id2b963ebad41a1ebdcceb73baf3436d59aac73a0
GitHub-Last-Rev: 9c2b9f7
GitHub-Pull-Request: #65745
Reviewed-on: https://go-review.googlesource.com/c/go/+/564735
Reviewed-by: Damien Neil <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
Reviewed-by: Jonathan Amsterdam <[email protected]>1 parent 7a64b0f commit 5225da7
1 file changed
+8
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| 27 | + | |
26 | 28 | | |
27 | 29 | | |
28 | 30 | | |
| |||
381 | 383 | | |
382 | 384 | | |
383 | 385 | | |
384 | | - | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
385 | 391 | | |
386 | 392 | | |
387 | 393 | | |
| |||
0 commit comments