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>
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
- 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
* 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
* fixed#3404 2022-11-23
* up 2022-11-23
* refactor: refactor context handling and nil checks
- Refactor nil checks to improve readability in `context.go`
- Modify the control flow in `HandlerNames` and `Next` methods to continue on nil values before appending or invoking handlers in `context.go`
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
* test: refactor context_test.go for clarity and efficiency
- Insert a `nil` value into the `HandlersChain` array in `context_test.go`
- Remove empty test functions in `context_test.go`
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
---------
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
Co-authored-by: Bo-Yi Wu <appleboy.tw@gmail.com>
* build: update Gin minimum Go version to 1.21
- Update the minimum Go version requirement for Gin from `1.20` to `1.21` in both `debug.go` and `debug_test.go`
- Modify the warning message to reflect the new minimum Go version requirement in `debug.go`
- Adjust the test assertion to match the updated warning message in `debug_test.go`
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
* docs: refine project documentation and CI configurations
- Update supported Go versions for GitHub actions to `1.21` and `1.22`
- Specify the required Go version as `1.21` or above in README
- Change code block syntax to `sh` in installation and demo run instructions
- Remove empty lines in README sections
- Update project list formatting without changing the content
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
---------
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
* experimental support http3
* remove go1.14 and go1.15
* update quic-go package path
* only support go1.19+
* remove go19 support
* update gomod
* chore: refine CI configuration and dependencies
- Remove dynamic Go versioning in favor of pinning to major version `1`
- Update linter version from `v1.56.2` to `v1.58.1` in GitHub Actions workflow
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
* chore: refactor CI workflow and improve tests
- Update the golangci-lint-action version from `v5` to `v6` in the GitHub workflow configuration
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
* chore: update dependencies and CI configurations
- Update Go version requirement from `1.20` to `1.21` in `go.mod`
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
* style: refactor codebase and update tests
- Add an empty line in the import section of `gin.go`
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
* chore: enhance code quality and consistency
- Add `gin.go` to the list of files with specific linters in `.golangci.yml`, applying the `gci` linter.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
---------
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
Co-authored-by: Bo-Yi Wu <appleboy.tw@gmail.com>
- Update the Go version requirements in `.github/workflows/gin.yml`
- Remove test files for Go versions 1.18 and 1.19
- Update the required Go version in `debug.go` and `debug_test.go`
- Rename and modify files related to Go version 1.19 and 1.20 in the `internal/bytesconv` directory
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
* docs: update documentation and release notes for Gin v1.10.0
- Add release notes for Gin v1.10.0
- Include new features and bug fixes in the changelog
- Document enhancements and build process updates
- Update documentation for context and middleware functions
- Upgrade dependencies and optimize unit tests
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
* feat: refactor CI, enhance file binding, and update dependencies
- Add proxy-server authentication feature
- Add support for custom BindUnmarshaler for binding
- Fix binding error while not uploading file
- Refactor CI and update dependencies
- Add support for RFC 9512: application/yaml
- Optimize the Copy method of the Context struct
- Update various Go dependencies to latest versions
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
---------
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
- Update `github.com/go-playground/validator/v10` from v10.19.0 to v10.20.0
- Update `github.com/pelletier/go-toml/v2` from v2.2.0 to v2.2.2
- Update `golang.org/x/net` from v0.22.0 to v0.25.0
- Update `google.golang.org/protobuf` from v1.33.0 to v1.34.1
- Update `golang.org/x/arch` from v0.7.0 to v0.8.0
- Update `golang.org/x/crypto` from v0.21.0 to v0.23.0
- Update `golang.org/x/sys` from v0.18.0 to v0.20.0
- Update `golang.org/x/text` from v0.14.0 to v0.15.0
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
- Update `github.com/bytedance/sonic` from v1.11.0 to v1.11.3
- Update `github.com/go-playground/validator/v10` from v10.18.0 to v10.19.0
- Update `github.com/pelletier/go-toml/v2` from v2.1.1 to v2.2.0
- Update `github.com/stretchr/testify` from v1.8.4 to v1.9.0
- Update `golang.org/x/net` from v0.21.0 to v0.22.0
- Update `golang.org/x/crypto` from v0.19.0 to v0.21.0
- Update `golang.org/x/sys` from v0.17.0 to v0.18.0
Signed-off-by: appleboy <appleboy.tw@gmail.com>
* chore: refactor changelog regex patterns and exclusions
- Update the build configuration to skip the build using a comment
- Change the `changelog` use from `git` to `github`
- Modify the regex patterns for `Features`, `Bug fixes`, and `Enhancements` titles in the changelog
- Add a new regex pattern for the `Refactor` title in the changelog
- Update the excluded items in the changelog to include `docs` and `CICD` with corrected quotes
Signed-off-by: appleboy <appleboy.tw@gmail.com>
* chore: update configuration file field names
- Change the `skip` field to `disable` in the `.goreleaser.yaml` file.
Signed-off-by: appleboy <appleboy.tw@gmail.com>
* update
Signed-off-by: appleboy <appleboy.tw@gmail.com>
* chore: refine changelog categorization rules
- Update regular expressions for `feat`, `fix`, and `chore` categories in `.goreleaser.yaml`
- Remove `Refactor` category from changelog configuration
- Add `Refactor` category with updated regular expression and order to changelog configuration
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
---------
Signed-off-by: appleboy <appleboy.tw@gmail.com>
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
* 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