[docs] Add example usage for Route.HeadersRegexp#320
Merged
kisielk merged 2 commits intogorilla:masterfrom Dec 4, 2017
Merged
Conversation
kisielk
suggested changes
Dec 1, 2017
Contributor
kisielk
left a comment
There was a problem hiding this comment.
Thanks for the examples, I think they are good. Just a few stylistic changes requested to group things together for clarity. Let me know if the comments don't make sense :)
| req1, _ := http.NewRequest("GET", "example.com", nil) | ||
| req2, _ := http.NewRequest("GET", "example.com", nil) | ||
|
|
||
| req1.Header.Add("Accept", "text/plain") |
Contributor
There was a problem hiding this comment.
Move next to the declaration of req1
example_route_test.go
Outdated
| func ExampleRoute_HeadersRegexp() { | ||
| r := mux.NewRouter() | ||
| route := r.NewRoute().HeadersRegexp("Accept", "html") | ||
| matchInfo := &mux.RouteMatch{} |
Contributor
There was a problem hiding this comment.
move to just before the fmt.Printf, leave a space here to separate the r and route from the rest.
example_route_test.go
Outdated
| route := r.NewRoute().HeadersRegexp("Accept", "html") | ||
| matchInfo := &mux.RouteMatch{} | ||
| req1, _ := http.NewRequest("GET", "example.com", nil) | ||
| req2, _ := http.NewRequest("GET", "example.com", nil) |
Contributor
There was a problem hiding this comment.
Move to just above the req2.Header.Set...
| // for the header value. Using the start and end of string anchors, the | ||
| // value must be an exact match. | ||
| func ExampleRoute_HeadersRegexp_exactMatch() { | ||
| r := mux.NewRouter() |
Contributor
There was a problem hiding this comment.
Similar changes to this function.
Contributor
Author
|
Wow, I'm surprised how much more readable that became, thanks. |
Contributor
|
Looks great. Thanks a lot! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements the documentation aspect of #124.
Updates the documentation comment header for
route.go:Route.HeadersRegexp. And also addsexample_route_test.gocontaining:ExampleRoute_HeadersRegexp. Demonstrates the wildcard behavior of Go'sregexp.Compile.ExampleRoute_HeadersRegexp_exactMatch. Demonstrates strict matching using start and end of string anchors.