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 #666

Closed
Algebra8 opened this issue Jan 18, 2022 · 2 comments · Fixed by #672
Closed

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

Algebra8 opened this issue Jan 18, 2022 · 2 comments · Fixed by #672

Comments

@Algebra8
Copy link

Algebra8 commented Jan 18, 2022

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")
@Algebra8
Copy link
Author

Fixed included #667 :)

@stale
Copy link

stale bot commented Apr 17, 2022

This issue has been automatically marked as stale because it hasn't seen a recent update. It'll be automatically closed in a few days.

@stale stale bot added the stale label Apr 17, 2022
@stale stale bot closed this as completed May 1, 2022
coreydaley added a commit that referenced this issue Aug 17, 2023
Fixes #666 

**Summary of Changes**

1. Update `Route` method documentation comments where the example in the
comments showed a `Router` before. Updated method names include:
    * `Headers`
    * `HeadersRegexp`
    * `Host`
    * `Path`
    * `Queries`
    * `Subrouter`
    * `URL`

Notes:
* This includes what PR #667 did plus some changes requested by a
maintainer in the comments
* I was a little torn about changing the example in `Subrouter` since
`(*Router).Host()` (like several `(*Router)` methods) just calls
`(*Router).NewRoute().Host()` so I understand if maintainers are
ambivalent about that example or want it to remain the same.

Signed-off-by: Corey Daley <[email protected]>
Co-authored-by: Andrew Brown <[email protected]>
Co-authored-by: Corey Daley <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant