31 Commits

Author SHA1 Message Date
Yash
8ea227bd0a
docs: fix example outputs and claims that differ from actual behavior
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
2026-10-26 00:04:07 +00:00
Little Fedya
0f09c3a9b4
docs: include HTTP QUERY method in RouterGroup.Any (#4879)
Co-authored-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2026-10-10 12:20:35 +08:00
adam magued
e8f24969d5
feat(routergroup): include HTTP QUERY method in Any (#4878)
Signed-off-by: AdamMagued <adamismailmageud@gmail.com>
2026-10-10 12:16:17 +08:00
Zain Qureshi
43fe48e8a0
docs: fix SecureJSON default prefix and default-binding example output (#4861)
The SecureJSON docs and the Context.SecureJSON comment said the default
prefix is "while(1),". The engine sets secureJSONPrefix to "while(1);"
(gin.go), and the example output a few lines below already shows the
semicolon.

The default-values binding example printed a "Colors" field that the
Person struct does not have; the struct's array field is Addresses
with default "foo bar", which binds to ["foo","bar"].

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 21:14:45 +08:00
Wahid Rizka Fathurrohman
8ad9f9cbea
docs: fix the graceful shutdown example (#4809)
The example calls errors.Is but never imports errors, so copying it as
written fails to build with "undefined: errors".

It also passes an unbuffered channel to signal.Notify, which go vet
reports as a misuse: signal delivery is non-blocking, so a signal that
arrives before the receive is dropped.
2026-09-19 14:21:21 +08:00
Gaurav Patil
b1f77cf536
feat(gin): add support for the HTTP QUERY method (RFC 10008) (#4806)
* feat: add support for the HTTP QUERY method (RFC 10008)

Add a QUERY shortcut on RouterGroup, a gin.MethodQuery constant and a
gin.IQueryRoutes interface for callers that only hold an IRoutes value.

QUERY is deliberately kept out of IRoutes and out of Any:

- Adding a method to IRoutes would break every type outside of Gin that
  implements it, such as test doubles and wrappers.
- Leaving Any untouched keeps existing catch-all routes matching exactly
  the methods they matched before. Match([]string{gin.MethodQuery, ...})
  covers the case where QUERY is wanted alongside other methods.

MethodQuery is declared in Gin because the standard library does not
provide http.MethodQuery yet. The value stays correct once it does.

Ref #4721

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* fix(router): remove duplicate QUERY method

- Consolidate QUERY into the existing router method after merging master
- Preserve the MethodQuery constant and request body documentation

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2026-09-19 14:20:37 +08:00
Bo-Yi Wu
d4672219fc
docs: reorganize doc.md TOC into thematic groups (#4579)
The flat TOC under a single "API Examples" heading made it hard to scan
and find relevant content. Reorganize 40+ sections into 7 logical groups
(Routing, Middleware, Logging, Request Binding & Validation, Response
Rendering, Server Configuration, Testing) with description lines for
each group. Move scattered sections into their correct groups and fix
the "avoid-loging-query-strings" anchor typo.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-13 22:30:54 +08:00
Jacob McSwain
db309081bc
chore(logger): allow skipping query string output (#4547)
This is useful for APIs that might have sensitive information in the query string, such as API keys.

This patch does not change the default behavior of the code unless the new `SkipQueryString` config option is passed in.

The "skip" term is a bit of a misnomer here, as this doesn't actually skip that log, but modifies the output. I'm open to suggestions for a more appropriate name.

Co-authored-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2026-02-27 23:33:46 +08:00
takanuva15
192ac89eef
feat(binding): add support for encoding.UnmarshalText in uri/query binding (#4203) 2026-01-24 15:20:24 +08:00
Tim
688a429d19
feat: support custom json codec at runtime (#3391)
* refactor(json): export json codec

* feat(json): support custom json codec at runtime

* chore(copyright): update copyright to 2025 gin core team

* docs(gin): add custom json codec examples in doc file
2025-06-16 23:16:36 +08:00
Victor Dusart
dd33ff7938
fix(docs): missing go markdown codeblock (#4266) 2025-06-16 22:59:53 +08:00
NARITA
fb09c825e8
feat(context): add SetCookieData (#4240)
* feat(context): add SetCookieStruct (#4215)# This is a combination of 2 commits.

feat(context): add SetCookieStruct (#4215)

feat(context): add SetCookieStruct (#4215)

* feat(context): add SetCookieStruct (#4215)

* feat(context): fix SetCookieStruct→SetCookieData (gin-gonic#4215)

* fix(context): respect caller-specified SameSite value in SetCookieData
2025-05-21 08:20:44 +08:00
Yash
7a1b655074
fix: sonic on arm64 (#4234) 2025-05-11 22:34:09 +08:00
sunshineplan
71496abe68
feat(fs): Implement loading HTML from http.FileSystem (#4053)
* Implement loading HTML from http.FileSystem

* Add OnlyHTMLFS test

* Move OnlyHTMLFS to internal and add test
2025-04-21 00:11:16 +08:00
Adlai Bridson-Boyczuk
1b53a47790
docs: Fixing English grammar mistakes and awkward sentence structure in doc/doc.md (#4207)
* docs: Fixing grammar mistakes and awkward sentences, such as modeling
binding section

* Update doc.md

Missed grammar mistake
2025-04-11 23:59:03 +08:00
takanuva15
4ccfa7c275
feat(binding): add support for unixMilli and unixMicro (#4190) 2025-03-20 23:33:10 +08:00
tsukasa-ino
299c6f30e3
docs: trimmed some white spaces (#4070) 2024-10-25 09:16:40 +08:00
takanuva15
f05f966a08
feat(form): Support default values for collections in form binding (#4048) 2024-09-21 23:24:18 +08:00
demouth
f2c861a24f
docs: fix route group example code (#4020) 2024-09-15 08:54:23 +08:00
Jo YoHan
3cb30679b5
feat(form): add array collection format in form binding (#3986)
* feat(form): add array collection format in form binding

* feat(form): add array collection format in form binding

* test(form): fix test code for array collection format in form binding
2024-08-24 14:16:30 +08:00
demouth
9c081de9cd
docs: fix typo in Gin Quick Start (#3997) 2024-06-16 00:28:08 +08:00
dkkb
a18219566c
feat(binding): Support custom BindUnmarshaler for binding. (#3933) 2024-05-07 09:43:15 +08:00
RedCrazyGhost
7a865dcf1d
feat(bind): ShouldBindBodyWith shortcut and change doc (#3871)
* feat: ShouldBindBodyWith shortcut and change doc

* fix: yaml can parse json test case

* style: fix new test case in context_test.go

* chore: modify the code style to specify binding type

* chroe: gofmt modifies the code format
2024-03-23 22:09:02 +08:00
Andy Brody
bb3519d26f
chore(IP): add TrustedPlatform constant for Fly.io. (#3839)
Also add some more detail to the docs for how to use TrustedPlatform.

https://fly.io/docs/reference/runtime-environment/#fly-client-ip
2024-02-07 20:18:53 +08:00
Ghobad
c6ae2e6966
feat(logger): ability to skip logs based on user-defined logic (#3593)
* log skipper

* do not call time.now() if logging should be skipped

* do not ignore skip func delay in latency calculation

* write docs

* write test
2024-02-02 09:52:26 +08:00
thinkerou
1e1f0b1e76
chore: support min go version 1.18 (#3511)
* chore: min go version 1.18

* fix build tag error

* remove build tag

* fix word

* remove any.go

* replace interface{} instead of any
2023-03-01 10:03:48 +08:00
apriil15
c58e0d59ca
docs: update markdown format (#3446)
* docs: update markdown format

* fix: resolve conflict

* docs: update markdown format

* docs: update

* docs: update

* Revert "docs: update"

This reverts commit 82716193b753dbcad6fee85973790727b7a31ae5.
2023-01-05 10:15:29 +08:00
thinkerou
82e1c53cc0
docs(readme): move more example to docs/doc.md (#3449) 2023-01-02 10:40:25 +08:00
田欧
9bacadd3ea remove docs dir (#1786)
the post doc move https://gin-gonic.com/blog/
2019-03-01 07:11:02 +08:00
Barnabus
f83cdb357e Fix typos (#1625) 2018-11-05 09:13:17 +08:00
田欧
98082fd590
document: add docs dir and middleware document (#1521)
* init docs dir

* add middleware document

* fix indent

* update docs
2018-10-15 13:01:44 +08:00