mirror of
https://github.com/golang/go.git
synced 2025-10-19 19:13:18 +00:00
net/http: clarify ServeMux.Handler behavior
Explain that ServeMux.Handler doesn't populate the request with matches. Fixes #69623. Change-Id: If625b3f8e8f4e54b05e1d9a86e8c471045e77763 Reviewed-on: https://go-review.googlesource.com/c/go/+/674095 Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Chressie Himpel <chressie@google.com> Reviewed-by: Sean Liao <sean@liao.dev> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
parent
3602cec3af
commit
177d5eb630
1 changed files with 5 additions and 0 deletions
|
@ -836,6 +836,7 @@ var copyBufPool = sync.Pool{New: func() any { return new([copyBufPoolSize]byte)
|
|||
func getCopyBuf() []byte {
|
||||
return copyBufPool.Get().(*[copyBufPoolSize]byte)[:]
|
||||
}
|
||||
|
||||
func putCopyBuf(b []byte) {
|
||||
if len(b) != copyBufPoolSize {
|
||||
panic("trying to put back buffer of the wrong size in the copyBufPool")
|
||||
|
@ -2674,6 +2675,10 @@ func stripHostPort(h string) string {
|
|||
//
|
||||
// If there is no registered handler that applies to the request,
|
||||
// Handler returns a “page not found” handler and an empty pattern.
|
||||
//
|
||||
// Handler does not modify its argument. In particular, it does not
|
||||
// populate named path wildcards, so r.PathValue will always return
|
||||
// the empty string.
|
||||
func (mux *ServeMux) Handler(r *Request) (h Handler, pattern string) {
|
||||
if use121 {
|
||||
return mux.mux121.findHandler(r)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue