Repository navigation
Conversation
Each of these was checked by running the example against the current
master branch with net/http/httptest.
- Parameters in path: the comment said routes starting with /user/groups
are never interpreted as /user/:name/... routes. GET /user/groups/admin
is served by /user/:name/*action with name "groups". Only the exact
path /user/groups goes to the static route.
- Map as querystring or postform parameters: fmt prints map keys in
sorted order, so the output is map[a:1234 b:hello] and
map[first:thinkerou second:tianou].
- JSONP: the response body is x({"foo":"bar"}); with plain quotes and a
trailing semicolon. The escaped quotes were copied from a Go string
literal in the tests.
- Model binding: when Bind fails, AbortWithError(400, err) sends the
headers with an empty body and no Content-Type. It does not set
text/plain; charset=utf-8.
- Set and get a cookie: the first example used SetCookieData and
http.Cookie without importing net/http and time, so it did not
compile, and it duplicated the SetCookieData example that follows it.
Restore the SetCookie call it used before SetCookieData was added.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NQDmA3mwGfL83pbg9WQ6ey
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #4914 +/- ##
==========================================
+ Coverage 98.65% 98.71% +0.06%
==========================================
Files 48 48
Lines 3188 3188
==========================================
+ Hits 3145 3147 +2
+ Misses 43 41 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
I ran the examples in
docs/doc.mdagainst current master withnet/http/httptestand compared the results with what the docs say. Five places do not match. This PR changes onlydocs/doc.md.What I changed
GET /user/groups/adminis served by/user/:name/*actionand returnsgroups is /admin. Only the exact path/user/groupsgoes to the static route. I rewrote the comment to say that.ids: map[b:hello a:1234]; names: map[second:tianou first:thinkerou].fmtprints map keys in sorted order (since Go 1.12), so the real output isids: map[a:1234 b:hello]; names: map[first:thinkerou second:tianou]. This does not depend on the environment.x({\"foo\":\"bar\"}). The real body isx({"foo":"bar"});, with plain quotes and a trailing semicolon. The escaped form looks like it was copied from the Go string literal incontext_test.go.BindsetsContent-Typetotext/plain; charset=utf-8. It does not.AbortWithError(400, err)writes the headers right away with an empty body and noContent-Type. Over a realhttptest.NewServer, the response headers are onlyContent-Length: 0andDate.SetCookieDataandhttp.Cookiebut does not importnet/httportime, so it does not compile (undefined: http). It is also the same code as theSetCookieDataexample right after it, which is introduced with "You can also use theSetCookieDatamethod". Before feat(context): add SetCookieData #4240 the first example usedc.SetCookie(...). I put that call back. It now compiles, and it sendsSet-Cookie: gin_cookie=test; Path=/; Domain=localhost; Max-Age=3600; HttpOnly.How I checked
For each item I copied the example into a small test module that points at this repo with a
replacedirective, ran it withgo test -v(Go 1.26.0), and printed the response. For the cookie examples I put each code block into its ownmainpackage and rango vet. The first one failed before this change and passes after it. The second one passes both before and after.Pull Request Checklist
masterbranch.docs/doc.md. (Not a feature.)