Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] Documentation for func (*Route) HeadersRegexp is incorrect #14

Open
tebruno99 opened this issue Dec 15, 2022 · 2 comments
Open

[bug] Documentation for func (*Route) HeadersRegexp is incorrect #14

tebruno99 opened this issue Dec 15, 2022 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@tebruno99
Copy link

tebruno99 commented Dec 15, 2022

MIGRATED - See upstream comments
From mux created by Algebra8: gorilla#666

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")
@tebruno99 tebruno99 added bug Something isn't working stale labels Dec 15, 2022
@tebruno99
Copy link
Author

tebruno99 commented Dec 15, 2022

MIGRATED
Original Comment: Algebra8 gorilla#666 (comment)

Fixed included gorilla#667 :)

@tebruno99 tebruno99 removed the stale label Dec 15, 2022
@tebruno99
Copy link
Author

Fix was approved in PR gorilla#667

@tebruno99 tebruno99 self-assigned this Dec 15, 2022
tebruno99 added a commit that referenced this issue Dec 15, 2022
MIGRATED: Fix minor mistake in HeadersRegexp doc #14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
1 participant