ItalyPaleAle
ecbeb4a594
Merge branch 'master' of https://github.com/gin-gonic/gin into bind-request-entity-too-large-2
2025-05-20 10:06:08 -07:00
Alessandro (Ale) Segala
3398188ad3
Update context.go
...
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-05-20 10:04:30 -07:00
Name
3d8e288c64
perf(all): use strings.Cut to replace strings.SplitN ( #4239 )
...
Co-authored-by: 1911860538 <alxps1911@gmail.com>
2025-05-20 22:58:34 +08:00
Salim Absi
2e2bd1f408
test(internal/fs): fix test function name ( #4235 )
2025-05-20 18:29:39 +08:00
Siddhesh Mhadnak
da67cc1b98
test: fix lint failures ( #4244 )
2025-05-20 18:16:21 +08:00
dependabot[bot]
ef68fa032c
chore(deps): bump golang.org/x/net from 0.38.0 to 0.40.0 ( #4229 )
...
Bumps [golang.org/x/net](https://github.com/golang/net ) from 0.38.0 to 0.40.0.
- [Commits](https://github.com/golang/net/compare/v0.38.0...v0.40.0 )
---
updated-dependencies:
- dependency-name: golang.org/x/net
dependency-version: 0.40.0
dependency-type: direct:production
update-type: version-update:semver-minor
...
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-05-11 22:42:01 +08:00
Orkhan Alikhanov
b38c59de7f
fix(errors): change Unwrap method receiver to value type ( #4232 )
2025-05-11 22:38:33 +08:00
dependabot[bot]
cf32d2dcf8
chore(deps): bump github.com/pelletier/go-toml/v2 from 2.2.2 to 2.2.4 ( #4212 )
...
Bumps [github.com/pelletier/go-toml/v2](https://github.com/pelletier/go-toml ) from 2.2.2 to 2.2.4.
- [Release notes](https://github.com/pelletier/go-toml/releases )
- [Changelog](https://github.com/pelletier/go-toml/blob/v2/.goreleaser.yaml )
- [Commits](https://github.com/pelletier/go-toml/compare/v2.2.2...v2.2.4 )
---
updated-dependencies:
- dependency-name: github.com/pelletier/go-toml/v2
dependency-version: 2.2.4
dependency-type: direct:production
update-type: version-update:semver-patch
...
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-05-11 22:35:03 +08:00
dependabot[bot]
4714c2a9a3
chore(deps): bump google.golang.org/protobuf from 1.34.1 to 1.36.6 ( #4198 )
...
Bumps google.golang.org/protobuf from 1.34.1 to 1.36.6.
---
updated-dependencies:
- dependency-name: google.golang.org/protobuf
dependency-type: direct:production
update-type: version-update:semver-minor
...
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-05-11 22:34:39 +08:00
Yash
7a1b655074
fix: sonic on arm64 ( #4234 )
2025-05-11 22:34:09 +08:00
ItalyPaleAle
2efd359c20
Bind: return 413 status code when error is http.MaxBytesError
...
The Go standard library includes a method `http.MaxBytesReader` that allows limiting the request body. For example, users can create a middleware like:
```go
func MiddlewareMaxBodySize(c *gin.Context) {
// Limit request body to 100 bytes
c.Request.Body = http.MaxBytesReader(c.Writer, c.Request.Body, 100)
c.Next()
}
```
When the body exceeds the limit, reading from the request body returns an error of type `http.MaxBytesError`.
This PR makes sure that when the error is of kind `http.MaxBytesError`, Gin returns the correct status code 413 (Request Entity Too Large) instead of a generic 400 (Bad Request).
2025-04-25 22:26:08 -07:00
Name
67c9d4ee11
refactor: replace magic number 128 with unicode.MaxASCII in AsciiJSON Render ( #4224 )
...
Co-authored-by: huangzw <huangzw@2345.com>
2025-04-21 22:05:28 +08:00
dependabot[bot]
bb82473103
chore(deps): bump github.com/quic-go/quic-go from 0.48.2 to 0.50.1 ( #4197 )
...
Bumps [github.com/quic-go/quic-go](https://github.com/quic-go/quic-go ) from 0.48.2 to 0.50.1.
- [Release notes](https://github.com/quic-go/quic-go/releases )
- [Changelog](https://github.com/quic-go/quic-go/blob/master/Changelog.md )
- [Commits](https://github.com/quic-go/quic-go/compare/v0.48.2...v0.50.1 )
---
updated-dependencies:
- dependency-name: github.com/quic-go/quic-go
dependency-type: direct:production
update-type: version-update:semver-minor
...
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-04-21 00:15:51 +08:00
dependabot[bot]
255af882db
chore(deps): bump github.com/go-playground/validator/v10 ( #4208 )
...
Bumps [github.com/go-playground/validator/v10](https://github.com/go-playground/validator ) from 10.22.1 to 10.26.0.
- [Release notes](https://github.com/go-playground/validator/releases )
- [Commits](https://github.com/go-playground/validator/compare/v10.22.1...v10.26.0 )
---
updated-dependencies:
- dependency-name: github.com/go-playground/validator/v10
dependency-version: 10.26.0
dependency-type: direct:production
update-type: version-update:semver-minor
...
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-04-21 00:14:45 +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
Name
0eb99493c2
perf: optimize AsciiJSON.Render method by using fmt.Appendf and reusing temp buffer ( #4175 )
...
per: use bytesconv.BytesToString(ret) instead of string(str)
Co-authored-by: 1911860538 <alxps1911@gmail.com>
2025-04-21 00:05:34 +08:00
dependabot[bot]
afa0c31d97
chore(deps): bump github.com/gin-contrib/sse from 0.1.0 to 1.1.0 ( #4216 )
...
Bumps [github.com/gin-contrib/sse](https://github.com/gin-contrib/sse ) from 0.1.0 to 1.1.0.
- [Release notes](https://github.com/gin-contrib/sse/releases )
- [Changelog](https://github.com/gin-contrib/sse/blob/master/.goreleaser.yaml )
- [Commits](https://github.com/gin-contrib/sse/compare/v0.1.0...v1.1.0 )
---
updated-dependencies:
- dependency-name: github.com/gin-contrib/sse
dependency-version: 1.1.0
dependency-type: direct:production
update-type: version-update:semver-major
...
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-04-21 00:02:02 +08:00
dependabot[bot]
56fccc39ec
chore(deps): bump golang.org/x/net from 0.37.0 to 0.38.0 ( #4221 )
...
Bumps [golang.org/x/net](https://github.com/golang/net ) from 0.37.0 to 0.38.0.
- [Commits](https://github.com/golang/net/compare/v0.37.0...v0.38.0 )
---
updated-dependencies:
- dependency-name: golang.org/x/net
dependency-version: 0.38.0
dependency-type: direct:production
...
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-04-21 00:01:35 +08:00
eduardo-ax
3319038418
fix(readme): fix broken link to English documentation ( #4222 )
...
Co-authored-by: Eduardo Alexandre <eduardoalexandree.ps>
2025-04-21 00:01:03 +08:00
NezhaFan
49e9137c68
docs: fix comment ( #4205 )
...
Co-authored-by: voyager1 <voyager1@voyager1deMacBook-Pro.local>
2025-04-12 00:00:59 +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
Andrey Bolonin
3afff295a2
docs: add Upd language list ( #4211 )
...
* Upd language list
* Update url
2025-04-11 23:58:02 +08:00
bound2
8763f33c65
fix: prevent middleware re-entry issue in HandleContext ( #3987 )
2025-03-20 23:40:41 +08:00
revevide
e737e3e267
fix(binding): prevent duplicate decoding and add validation in decodeToml ( #4193 )
2025-03-20 23:35:49 +08:00
takanuva15
4ccfa7c275
feat(binding): add support for unixMilli and unixMicro ( #4190 )
2025-03-20 23:33:10 +08:00
Bo-Yi Wu
90cf460269
chore: update Go versions and dependencies for improved compatibility ( #4187 )
...
* chore: update Go versions and dependencies for improved compatibility
- Update Go versions in workflow file to `1.23` and `1.24`
- Enhance test tags in workflow with specific linker flags
- Remove the conditional formatting step for Go `1.22.x` in workflow
- Remove `goimports` settings from `.golangci.yml`
- Update `go.mod` to use Go `1.23.0`
- Upgrade `github.com/bytedance/sonic` from `v1.11.6` to `v1.13.1`
- Update indirect dependencies `sonic/loader` to `v0.2.4` and `base64x` to `v0.1.5` in `go.mod`
Signed-off-by: appleboy <appleboy.tw@gmail.com>
* chore: update project for Go 1.23 compatibility and documentation fixes
- Update Go version requirement from 1.22 to 1.23 in README.md
- Remove superfluous `$` from example command in README.md
- Update warning message to reflect new Go version requirement in debug.go
- Update test assertion to reflect new Go version requirement in debug_test.go
Signed-off-by: appleboy <appleboy.tw@gmail.com>
---------
Signed-off-by: appleboy <appleboy.tw@gmail.com>
2025-03-20 10:13:47 +08:00
Name
ebe5e2a6bf
fix(golangci.yml): move fiximports to goimports section and replace exportloopref with copyloopvar ( #4167 )
...
Co-authored-by: huangzw <huangzw@2345.com>
2025-03-18 23:13:03 +08:00
dependabot[bot]
733ee094fc
chore(deps): bump golang.org/x/net from 0.33.0 to 0.37.0 ( #4178 )
...
Bumps [golang.org/x/net](https://github.com/golang/net ) from 0.33.0 to 0.37.0.
- [Commits](https://github.com/golang/net/compare/v0.33.0...v0.37.0 )
---
updated-dependencies:
- dependency-name: golang.org/x/net
dependency-type: direct:production
update-type: version-update:semver-minor
...
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-03-18 22:15:13 +08:00
NezhaFan
a4baac6e5e
refactor(context):Avoid using filepath.Dir twice in SaveUploadedFile ( #4181 )
...
Co-authored-by: voyager1 <voyager1@voyager1deMacBook-Pro.local>
2025-03-18 22:14:38 +08:00
NezhaFan
1eb827240e
docs: fix case error of X-Real-IP ( #4185 )
...
Co-authored-by: voyager1 <voyager1@voyager1deMacBook-Pro.local>
2025-03-18 22:12:36 +08:00
Bo-Yi Wu
3b28645dc9
ci: add go version 1.24 to GitHub Actions ( #4154 )
...
- Add Go version `1.24` to the GitHub Actions workflow
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2025-02-12 10:22:02 +08:00
dependabot[bot]
c3c8620a7f
chore(deps): bump github.com/go-playground/validator/v10 from 10.20.0 to 10.22.1 ( #4052 )
...
Bumps [github.com/go-playground/validator/v10](https://github.com/go-playground/validator ) from 10.20.0 to 10.22.1.
- [Release notes](https://github.com/go-playground/validator/releases )
- [Commits](https://github.com/go-playground/validator/compare/v10.20.0...v10.22.1 )
---
updated-dependencies:
- dependency-name: github.com/go-playground/validator/v10
dependency-type: direct:production
update-type: version-update:semver-minor
...
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-02-12 08:50:51 +08:00
Bo-Yi Wu
3f818c3fa6
chore(security): upgrade quic-go version to 0.48.2 ( #4127 )
...
- Update Go versions in GitHub Actions workflow to `1.22` and `1.23`
- Update README to require Go version `1.22` or above
- Adjust table formatting in README for better alignment
- Update warning message in `debug.go` to reflect Go version `1.22`
- Update test in `debug_test.go` to reflect Go version `1.22`
- Update `go.mod` to require Go version `1.22`
- Update dependencies in `go.mod` to newer versions
Signed-off-by: appleboy <appleboy.tw@gmail.com>
2024-12-30 11:40:37 +08:00
Bo-Yi Wu
23d6961aeb
ci(lint): update workflows and improve test request consistency ( #4126 )
...
- Update GoReleaser action to version 6 in GitHub workflow
- Use `http.MethodPost` constant in test requests instead of hardcoded string
Signed-off-by: appleboy <appleboy.tw@gmail.com>
2024-12-30 11:39:24 +08:00
Xianglin Gao
e2e80f3347
chore(security): update vendor to fix CVE ( #4121 )
...
Signed-off-by: Xianglin Gao <xianglingao@tencent.com>
2024-12-28 17:18:03 +08:00
haesuo566
e46bd52185
refactor(context): add an optional permission parameter to the SaveUploadedFile method ( #4068 ) ( #4088 )
...
Co-authored-by: hso <hso@trinitysoft.co.kr>
2024-11-15 23:54:06 +08:00
Matthieu MOREL
e8d34d053f
ci(lint): enable usestdlibvars linter ( #4091 )
...
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2024-11-15 23:52:16 +08:00
Matthieu MOREL
02c1144f31
ci(lint): enable perfsprint linter ( #4090 )
...
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2024-11-15 23:51:12 +08:00
Bo-Yi Wu
f875d87283
chore(context): test context initialization and handler logic ( #4087 )
...
* enhance code imported by #3413
if it needs to check if the handler is nil, tie c.index shall
always ++
* test: refactor test context initialization and handler logic
- Remove an empty line in `TestContextInitQueryCache`
- Add `TestContextNext` function with tests for `Next` method behavior with no handlers, one handler, and multiple handlers
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
---------
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
Co-authored-by: zjj <zhong2plus@gmail.com>
2024-11-15 23:49:08 +08:00
Konovalov Maxim
c8a3adc657
refactor(context): simplify "GetType()" functions ( #4080 )
...
This PR introduces a generic function, getTyped[T any], to simplify value retrieval in the Context struct. It replaces repetitive type assertions in the GetString GetBool etc. methods.
Co-authored-by: Maksim Konovalov <maksim.konovalov@vk.team>
2024-10-29 23:24:53 +08:00
Xinyu Kuo
ea53388e6e
fix(tree): Keep panic infos consistent when wildcard type build faild ( #4077 )
2024-10-26 08:28:59 +08:00
Oskar Karpiński
9d11234efe
docs(gin): Replace broken link to documentation with valid ( #4064 )
2024-10-26 08:26:25 +08:00
Xinyu Kuo
647311aba2
refactor(context): refactor context handling and improve test robustness ( #4066 )
...
Use assert.InDelta for float comparison with tolerance in TestContextGetFloat32
Remove unnecessary blank line in TestContextInitQueryCache
Replace anonymous struct with named contextKey type in TestContextWithFallbackValueFromRequestContext
Update context key handling in TestContextWithFallbackValueFromRequestContext to use contextKey type
2024-10-25 09:33:31 +08:00
tsukasa-ino
299c6f30e3
docs: trimmed some white spaces ( #4070 )
2024-10-25 09:16:40 +08:00
Enzo Lanzellotti
b080116a7f
docs(readme): add Portuguese documentation. ( #4078 )
2024-10-25 09:08:11 +08:00
wangjingcun
ad740d508f
docs(context): fix some function names in comment ( #4079 )
2024-10-25 09:07:03 +08:00
takanuva15
f05f966a08
feat(form): Support default values for collections in form binding ( #4048 )
2024-09-21 23:24:18 +08:00
CC11001100
9d7c0e9e1a
feat(context): GetXxx added support for more go native types ( #3633 )
2024-09-15 08:58:59 +08:00
demouth
f2c861a24f
docs: fix route group example code ( #4020 )
2024-09-15 08:54:23 +08:00
Ahmad Saeed Goda
28e57f58b1
fix(form): Set default value for form fields ( #4047 )
...
- Use specified default value in struct tags when binding a request input to struct for validation, even if sent empty, not only when not sent at all.
- Add string field to `TestMappingDefault` test case.
- Add test case for not sent form field to default to the value specified via code.
- Add test case for form field sent empty to default to the value specified via code.
Fixes: How to apply default value if empty value provided by client during model binding? #4042 , #13042df, #a41721a
2024-09-06 13:21:19 +08:00