mirror of
https://github.com/golang/go
synced 2024-11-23 03:30:02 -07:00
net/http: fix ServeMux pattern registration
When the httpmuxgo121 GODEBUG setting was active, we were registering patterns in the old and the new way. Fix to register only in the old way. Change-Id: Ibc1fd41e7f4d162ee5bc34575df409e1db5657cd Reviewed-on: https://go-review.googlesource.com/c/go/+/533095 Run-TryBot: Jonathan Amsterdam <jba@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Olena Synenka <olenasynenka@google.com> Reviewed-by: Damien Neil <dneil@google.com>
This commit is contained in:
parent
008dabcd19
commit
62bdbd2596
@ -2686,8 +2686,9 @@ func (mux *ServeMux) ServeHTTP(w ResponseWriter, r *Request) {
|
||||
func (mux *ServeMux) Handle(pattern string, handler Handler) {
|
||||
if use121 {
|
||||
mux.mux121.handle(pattern, handler)
|
||||
} else {
|
||||
mux.register(pattern, handler)
|
||||
}
|
||||
mux.register(pattern, handler)
|
||||
}
|
||||
|
||||
// HandleFunc registers the handler function for the given pattern.
|
||||
@ -2696,8 +2697,9 @@ func (mux *ServeMux) Handle(pattern string, handler Handler) {
|
||||
func (mux *ServeMux) HandleFunc(pattern string, handler func(ResponseWriter, *Request)) {
|
||||
if use121 {
|
||||
mux.mux121.handleFunc(pattern, handler)
|
||||
} else {
|
||||
mux.register(pattern, HandlerFunc(handler))
|
||||
}
|
||||
mux.register(pattern, HandlerFunc(handler))
|
||||
}
|
||||
|
||||
// Handle registers the handler for the given pattern in [DefaultServeMux].
|
||||
@ -2705,8 +2707,9 @@ func (mux *ServeMux) HandleFunc(pattern string, handler func(ResponseWriter, *Re
|
||||
func Handle(pattern string, handler Handler) {
|
||||
if use121 {
|
||||
DefaultServeMux.mux121.handle(pattern, handler)
|
||||
} else {
|
||||
DefaultServeMux.register(pattern, handler)
|
||||
}
|
||||
DefaultServeMux.register(pattern, handler)
|
||||
}
|
||||
|
||||
// HandleFunc registers the handler function for the given pattern in [DefaultServeMux].
|
||||
@ -2714,8 +2717,9 @@ func Handle(pattern string, handler Handler) {
|
||||
func HandleFunc(pattern string, handler func(ResponseWriter, *Request)) {
|
||||
if use121 {
|
||||
DefaultServeMux.mux121.handleFunc(pattern, handler)
|
||||
} else {
|
||||
DefaultServeMux.register(pattern, HandlerFunc(handler))
|
||||
}
|
||||
DefaultServeMux.register(pattern, HandlerFunc(handler))
|
||||
}
|
||||
|
||||
func (mux *ServeMux) register(pattern string, handler Handler) {
|
||||
|
Loading…
Reference in New Issue
Block a user