gin icon indicating copy to clipboard operation
gin copied to clipboard

Support custom json codec at runtime

Open timandy opened this issue 1 year ago • 12 comments

Extract out an interface api.JsonApi to restrict all serialization and deserialization behaviors.

Developers only need to implement this interface and cover json.API value can realize custom json codec.

In the future, we can define api.XmlApi in the same way.

Solved #3217

timandy avatar Jul 01 '22 08:07 timandy

Codecov Report

Merging #3222 (c654eb0) into master (a0acf1d) will increase coverage by 0.10%. The diff coverage is 100.00%.

:exclamation: Current head c654eb0 differs from pull request most recent head 8bbf3eb. Consider uploading reports for the commit 8bbf3eb to get more accurate results

@@            Coverage Diff             @@
##           master    #3222      +/-   ##
==========================================
+ Coverage   98.27%   98.37%   +0.10%     
==========================================
  Files          42       43       +1     
  Lines        3137     3148      +11     
==========================================
+ Hits         3083     3097      +14     
+ Misses         40       38       -2     
+ Partials       14       13       -1     
Flag Coverage Δ
?
go-1.15 98.37% <100.00%> (?)
go-1.16 98.35% <100.00%> (∅)
go-1.17 98.28% <100.00%> (+0.10%) :arrow_up:
go-1.18 98.28% <100.00%> (+0.10%) :arrow_up:
go-1.19 ?
macos-latest 98.37% <100.00%> (+0.19%) :arrow_up:
nomsgpack 98.35% <100.00%> (?)
ubuntu-latest 98.37% <100.00%> (+0.10%) :arrow_up:

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
binding/form_mapping.go 100.00% <100.00%> (ø)
binding/json.go 100.00% <100.00%> (ø)
errors.go 100.00% <100.00%> (ø)
render/json.go 83.14% <100.00%> (ø)
mode.go 100.00% <0.00%> (ø)
tree.go 100.00% <0.00%> (ø)
routergroup.go 100.00% <0.00%> (ø)
test_helpers.go 100.00% <0.00%> (ø)
binding/binding_nomsgpack.go 100.00% <0.00%> (ø)
... and 1 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

codecov[bot] avatar Jul 01 '22 09:07 codecov[bot]

@thinkerou PTAL, thks.

timandy avatar Jul 01 '22 09:07 timandy

@thinkerou Could you make a code review for this PR. Thanks a lot.

timandy avatar Jul 04 '22 01:07 timandy

@thinkerou @appleboy Please make a code review, thanks. We really need this feature in our project.

timandy avatar Jul 06 '22 01:07 timandy

please also update readme, and add example code, thanks

thinkerou avatar Jul 06 '22 14:07 thinkerou

please also update readme, and add example code, thanks

@thinkerou I extract out an interface api.JsonApi to restrict all serialization and deserialization behaviors.

Developers only need to implement this interface and cover json.API value can realize custom json codec.

In the future, we can define api.XmlApi in the same way.

And I also add examples in readme.

PTAL, thanks.

timandy avatar Jul 07 '22 02:07 timandy

@thinkerou

timandy avatar Jul 08 '22 02:07 timandy

@appleboy PLTA, thanks very much.

timandy avatar Jul 12 '22 07:07 timandy

@timandy thanks a lot! the pull request have big modification and please review @appleboy @javierprovecho

thinkerou avatar Jul 14 '22 01:07 thinkerou

@thinkerou In the previous force push, I fixed the format of the example in the readme file.

timandy avatar Jul 17 '22 03:07 timandy

Any progress?

timandy avatar Jul 22 '22 06:07 timandy

@appleboy @thinkerou @javierprovecho Please take a look

timandy avatar Aug 03 '22 12:08 timandy