Commit Graph

135 Commits

Author SHA1 Message Date
Aum Patel
052d1a79aa
feat(render): add PDF renderer and tests (#4491)
* render: add PDF renderer and tests

* render: update PDF renderer copyright header

* test: add PDF rendering tests including 204 No Content in context_test.go
2026-02-28 21:04:54 +08:00
Amirhf
6f1d5fe3cd
test(render): add comprehensive error handling tests (#4541)
* test(render): add comprehensive error handling tests
Add error case tests for XML, Data, BSON, and HTML renderers to improve test coverage and ensure proper error handling:

- TestRenderXMLError: validates XML marshal error handling for unsupported types
- TestRenderDataError: validates Data write error handling
- TestRenderBSONError: validates BSON marshal error handling for unsupported types
- TestRenderBSONWriteError: validates BSON write error handling
- TestRenderHTMLTemplateError: validates HTML template execution error with invalid field access
- TestRenderHTMLTemplateExecuteError: validates HTML template execution error with invalid nested field

All tests pass and maintain 100% coverage for the render package.

* test(render): improve robustness of error handling tests based on PR feedback

---------

Co-authored-by: Bo-Yi Wu <appleboy.tw@gmail.com>
Co-authored-by: AmirHossein Fallah <amirhossein.fallah@arvancloud.ir>
2026-02-28 10:11:57 +08:00
Denis Galeev
5c00df8afa
fix(render): write content length in Data.Render (#4206)
* init test

* fix test

* fix assert.EqualValues usage

---------

Co-authored-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2026-02-28 10:07:31 +08:00
Bob Du
ba093d1947
chore(binding): upgrade bson dependency to mongo-driver v2 (#4549)
Signed-off-by: Bob Du <i@bobdu.cc>
2026-02-27 23:20:01 +08:00
Amirhf
216a4a7c28
test(render): add comprehensive tests for MsgPack render (#4537)
* test(render): add comprehensive tests for MsgPack render

* test(render): make msgpack tests deterministic

Decode the rendered msgpack output and assert values instead of comparing raw bytes (which can vary with map iteration order).
Enable MsgpackHandle.RawToString so msgpack strings decode as Go strings.

---------

Co-authored-by: AmirHossein Fallah <amirhossein.fallah@arvancloud.ir>
2026-02-18 00:38:36 +08:00
Laurent Caumont
d7776de7d4
feat(render): add bson protocol (#4145) 2026-01-27 10:09:01 +08:00
Name
e198f6e859
refactor(render): remove headers parameter from writeHeader (#4353)
Co-authored-by: 1911860538 <alxps1911@gmail.com>
2025-09-19 08:39:17 +08:00
Varus Hsu
17d0b553ea
chore(render): do not export tomlContentType anymore (#4319) 2025-08-02 12:27:59 +08:00
M. Ilham Surya Pratama
cf4775283e
chroe: migrate yaml package to github.com/goccy/go-yaml (#4272) 2025-06-21 12:38:28 +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
Flc゛
848e1cdd0d
refactor: replace interface{} with any in type declarations (#4249)
- Update golangci.yml to use 'any' instead of 'interface{}' in gofmt
- Modify debug.go, plain.go, and render_test.go to use 'any' type
- Improve code readability and follow modern Go conventions

Signed-off-by: Flc <four_leaf_clover@foxmail.com>
2025-05-26 23:11:05 +08:00
Flc゛
c4287b1300
ci(golangci-lint): update configuration and fix lint issues (#4247)
* ci: update golangci-lint configuration and lint settings

- Update golangci-lint to version 2
- Enable new linters and adjust existing ones
- Update lint settings across multiple test files
- Remove unused struct and variable checks
- Add new lint exclusions for generated code and specific directories

Signed-off-by: Flc <four_leaf_clover@foxmail.com>

* ci(github): update golangci-lint-action to v8 and lint version to v2.3.4

Signed-off-by: Flc <four_leaf_clover@foxmail.com>

* ci: downgrade golangci-lint to v2.1.6

Signed-off-by: Flc <four_leaf_clover@foxmail.com>

* ci(golangci): add gofumpt linter and fix related issues- Added gofumpt linter to .golangci.yml

Signed-off-by: Flc <four_leaf_clover@foxmail.com>

* test: ignore testifylint and gofumpt lints in specific test cases

Signed-off-by: Flc <four_leaf_clover@foxmail.com>

* build(deps): remove golang.org/x/lint

- Remove golang.org/x/lint package from go.mod
- Update related dependencies in go.sum

Signed-off-by: flc1125 <four_leaf_clover@foxmail.com>

* build(deps): downgrade golang.org/x/mod and golang.org/x/tools

- Downgrade golang.org/x/mod from v0.24.0 to v0.18.0
- Downgrade golang.org/x/tools from v0.33.0 to v.22.0

These changes are made to address compatibility issues with the current project setup.

Signed-off-by: flc1125 <four_leaf_clover@foxmail.com>

---------

Signed-off-by: Flc <four_leaf_clover@foxmail.com>
Signed-off-by: flc1125 <four_leaf_clover@foxmail.com>
2025-05-23 14:46:48 +08: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
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
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
5f55c6a711
ci(lint): enable testifylint linter (#4010)
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2024-07-14 20:33:08 +08:00
jessetang
3ea8bd99fb
chore(refactor): modify interface check way (#3855)
Signed-off-by: demoManito <1430482733@qq.com>
2024-03-06 22:27:21 +08:00
Vincent Bernat
9c61295efe
chore(header): Add support for RFC 9512: application/yaml (#3851)
* fix(binding): support application/yaml

RFC 9512 defines application/yaml as the official YAML MIME type.
application/x-yaml is deprecated. In this commit, we ensure it is
recognized correctly in Content-Type.

* fix(render): use application/yaml when rendering YAML

As per RFC 9512, application/x-yaml is now deprecated and applications
should use application/yaml. This commit fix the Content-Type header
when rendering YAML.
2024-03-05 21:54:35 +08:00
Leonardo de Araujo
bb2d8cf486
test(render): increased unit tests coverage (#3691) 2023-08-12 22:21:56 +08:00
ccpro
6a0556ed5a
improve render code coverage (#3525) 2023-05-10 17:19: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
Vladislav Dmitriyev
0c96a20209
Stop useless panicking in context and render (#2150)
Co-authored-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2023-02-12 10:01:33 +08:00
thinkerou
c9b27249fb
chore(yaml): upgrade dependency to v3 version (#3456)
fixes https://github.com/gin-gonic/gin/issues/3451
fixes https://github.com/gin-gonic/gin/issues/3306
fixes https://github.com/gin-gonic/gin/issues/3362
fixes https://github.com/gin-gonic/gin/issues/2581
2023-01-02 12:40:48 +08:00
mstmdev
e868fd1d3d
test(TOML): Add some tests for the TOML render (#3401) 2022-12-22 23:18:47 +08:00
hopehook
33ab0fc155
refactor(struct): Remove redundant type conversions (#3345) 2022-10-16 09:49:24 +08:00
thinkerou
38eb5acc6b
add v1.8.0 changelog (#3160) 2022-05-30 15:16:10 +08:00
thinkerou
4b68a5f12a
chore: update go.mod and remove space from copyright (#3158)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-28 10:42:28 +08:00
Valentine Oragbakosi
ed03102ef0
[GIN-001] - Add TOML bining for gin (#3081)
Co-authored-by: GitstartHQ <gitstart@users.noreply.github.com>
2022-05-28 08:34:43 +08:00
thinkerou
2bde107686
test support go1.18 (#2990) 2022-03-21 09:43:17 +08:00
Matthieu MOREL
71f7087097
golangci(lint) : more linters (#2870) 2021-09-21 15:22:21 +08:00
Lanco
4e7584175d
minor tweaks,optimize code (#2788) 2021-08-23 01:32:41 +08:00
Matthieu MOREL
435a76b735
chore(ci): update dependencies (#2827)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Matthieu MOREL <mmorel-35@users.noreply.github.com>
2021-08-19 15:46:31 +08:00
ziheng
f2bbdfe9f2
Use buf.String() instead of string(buf.Bytes()) (#2764) 2021-06-25 12:14:06 +08:00
heige
97a32b1de3
Optimize code adjust (#2700)
* setFormMap error of result

* adjust code for TrySet

* error export for type multipart.FileHeader

* code style adjust

* reflect code maping optimize

* Update form_mapping.go

Co-authored-by: Bo-Yi Wu <appleboy.tw@gmail.com>
Co-authored-by: thinkerou <thinkerou@gmail.com>
2021-06-02 07:35:30 +08:00
thinkerou
ed6f85c478
build: convert to go:build directives (#2664) 2021-03-27 09:09:44 +08:00
xyb
c83a1cca0a
reduce allocs and improve the render WriteString (#2508)
Co-authored-by: yonbiaoxiao <yonbiaoxiao@tencent.com>
Co-authored-by: Bo-Yi Wu <appleboy.tw@gmail.com>
Co-authored-by: thinkerou <thinkerou@gmail.com>
2020-10-16 18:32:33 +08:00
bestgopher
9221381443
remove a unused type SecureJSONPrefix (#2391) 2020-05-24 10:58:28 +08:00
Bo-Yi Wu
6f3d96ccff
chore: improve render string performance (#2365) 2020-05-09 17:41:00 +08:00
Kaushik Neelichetty
5f56109bcf
Use json marshall in context json to fix breaking new line issue. Fixes #2209 (#2228)
* ignore IntelliJ idea generated files

* update JSON renderer to use Marshall() instead of Encode(). Fix #2209

* Revert "ignore IntelliJ idea generated files"

This reverts commit e7bd017227.

Co-authored-by: Bo-Yi Wu <appleboy.tw@gmail.com>
Co-authored-by: thinkerou <thinkerou@gmail.com>
2020-02-21 17:15:17 +08:00
Andy Pan
982daeb1ec Use zero-copy approach to convert types between string and byte… (#2206)
* Use zero-copy approach to convert types between string and byte slice

* Rename argument to a eligible one

Benchmark:

BenchmarkBytesConvBytesToStrRaw-4   	21003800	        70.9 ns/op	      96 B/op	       1 allocs/op
BenchmarkBytesConvBytesToStr-4      	1000000000	         0.333 ns/op	       0 B/op	       0 allocs/op
BenchmarkBytesConvStrToBytesRaw-4   	18478059	        59.3 ns/op	      96 B/op	       1 allocs/op
BenchmarkBytesConvStrToBytes-4      	1000000000	         0.373 ns/op	       0 B/op	       0 allocs/op


Co-authored-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2020-01-18 00:32:50 +08:00
Antoine GIRARD
fd8a65b252 Add build tag nomsgpack (#1852)
* add build tag nomsgpack

* Update copyright

* Update copyright
2020-01-07 11:31:10 +08:00
Dmitry Kutakov
b52a1a1588 allow empty headers on DataFromReader (#2121) 2019-11-25 10:45:53 +08:00
Dmitry Kutakov
393a63f3b0 Fix 'errcheck' linter warnings (#2093) 2019-10-27 13:58:59 +08:00
Gaozhen Ying
9aa870f108 Adjust Render.Redirect test case (#2053) 2019-09-10 17:16:37 +08:00
George Gabolaev
01ca625b98 Fixed JSONP format (added semicolon) (#2007)
* Fixed JSONP format (added semicolon)

* render_test fix
2019-09-02 20:18:08 +08:00
Segev Finer
20440b96b9 Support negative Content-Length in DataFromReader (#1981)
You can get an http.Response with ContentLength set to -1 (Chunked encoding), so
for DataFromReader to be useful for those we need to support that.
2019-08-05 09:42:59 +08:00
Christian Muehlhaeuser
461df9320a Simplify code (#2004)
- Use buf.String instead of converison
- Remove redundant return
2019-07-27 09:06:37 +08:00
itcloudy
0cbf290302 use encode replace json marshal increase json encoder speed (#1546) 2019-05-22 07:48:50 +08:00
Dan Markham
094f9a9105 v1.4.0 + #1631 (remove go1.6/go1,7 support) (#1851)
* remove go1.6 support

* remove build tag

* remove todo

* remove go1.6 support: https://github.com/gin-gonic/gin/pull/1383/commits

* update readme

* remove go1.7 support

* fix embedmd error

* test

* revert it

* revert it

* remove context_17

* add pusher test

* v1.4.0 rc1
2019-05-07 18:32:32 +08:00