-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Closed
Description
Describe the bug
The documentation example for func (*Route) HeadersRegexp
is incorrect:
r := mux.NewRouter()
r.HeadersRegexp("Content-Type", "application/(text|json)",
"X-Requested-With", "XMLHttpRequest")
mux.NewRouter()
returns *mux.Router
but HeadersRegexp
is defined on *Route
. This is a small mistake and is not a major issue because the next (more verbose) example clarifies the mistake.
However, it's a mistake.
Should be something like:
r := mux.NewRouter().NewRoute()
r.HeadersRegexp("Content-Type", "application/(text|json)",
"X-Requested-With", "XMLHttpRequest")
Versions
Go version:
go version
go version go1.16.4 darwin/amd64
package version: run
git rev-parse HEAD
inside the repo
91708ff
Steps to Reproduce
How can the bug be triggered?
"Bug" is in documentation; triggered by looking at it.
Expected behavior
What output or behaviour were you expecting instead?
As mentioned above, the example should look like:
r := mux.NewRouter().NewRoute()
r.HeadersRegexp("Content-Type", "application/(text|json)",
"X-Requested-With", "XMLHttpRequest")