ProblemDetails() renders errors attached via Context.Error as an RFC 9457
problem details JSON response when the handler chain finishes without
writing a response. The response status code is kept when it is an error
status, otherwise it defaults to 500 Internal Server Error.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Add first-class support for RFC 9457 "Problem Details for HTTP APIs"
error responses in JSON format:
- gin.Problem type with the standard members (type, title, status,
detail, instance) and extension members serialized at the top level
- render.ProblemJSON renderer setting Content-Type to
"application/problem+json; charset=utf-8"
- Context.ProblemJSON and Context.AbortWithProblemJSON helpers; when
given a gin.Problem, a zero Status defaults to the response code and
an empty Title defaults to http.StatusText
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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>
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>
* 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
* 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