Skip to content

Conversation

@laurentcau
Copy link

@laurentcau laurentcau commented Jan 22, 2025

Add bson protocol for body encoding/decoding

@laurentcau laurentcau force-pushed the bson branch 3 times, most recently from 78408cb to 1e84634 Compare January 23, 2025 10:02
@laurentcau
Copy link
Author

ping
@manucorporat
@javierprovecho

binding/bson.go Outdated
@@ -0,0 +1,30 @@
// Copyright 2014 Manu Martinez-Almeida. All rights reserved.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// Copyright 2025 Gin Core Team. All rights reserved.
// Use of this source code is governed by a MIT style
// license that can be found in the LICENSE file.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi @laurentcau Please update the header.

@appleboy appleboy added this to the v1.11 milestone Feb 12, 2025
@appleboy appleboy requested a review from Copilot May 20, 2025 10:49
@appleboy
Copy link
Member

Please rebase the master branch.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for BSON encoding/decoding to the project, primarily by introducing new rendering and binding functionality along with corresponding tests.

  • Adds BSON render implementation in the render package with associated tests.
  • Extends context negotiation logic to support BSON responses.
  • Provides BSON binding support in the binding package with tests and updates to go.mod.

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
render/render_test.go Added tests for BSON rendering.
render/bson.go Introduces the BSON render logic for HTTP responses.
go.mod Adds mongo-driver dependency.
context_test.go Includes tests for BSON negotiation.
context.go Adds MIMEBSON constant and BSON response method.
binding/bson.go Implements BSON binding for request bodies.
binding/binding_test.go Extends tests to cover BSON binding.
binding/binding.go Updates binding mapping to include BSON.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for encoding/decoding BSON in the framework by introducing a new render type, updating content negotiation, and wiring BSON binding in the binding package.

  • Added BSON render implementation and corresponding tests in render/render_test.go
  • Updated context and binding files to include BSON handling for both response rendering and data binding
  • Updated go.mod to include the mongo-driver dependency

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
render/render_test.go Added tests for BSON rendering
render/bson.go Introduced BSON render type and content type writer
go.mod Added mongo-driver dependency
context_test.go Added test for context negotiation with BSON
context.go Extended context with BSON support in Negotiate and helper
binding/bson.go Introduced BSON binding implementation
binding/binding.go Updated default binding to support BSON
binding/binding_test.go Added BSON binding tests
Comments suppressed due to low confidence (1)

binding/binding_test.go:747

  • In the negative test branch for BSON binding, the test uses JSON.Bind instead of the expected BSON binding. Consider using b.Bind(req, &obj) (or BSON.Bind(req, &obj)) to properly test error handling in the BSON binding implementation.
err = JSON.Bind(req, &obj)

@appleboy appleboy changed the title add bson protocol feat(render): add bson protocol May 20, 2025
@appleboy
Copy link
Member

Testing fails.

@laurentcau
Copy link
Author

laurentcau commented May 21, 2025

Testing fails.

Error: ./context.go:40:34: undefined: binding.MIMEBSON
Error: ./context.go:1272:15: undefined: binding.MIMEBSON
It looks like "ubuntu-latest @ Go 1.23 -tags nomsgpack (pull_request)" doesn't use the right binding/binding.go file because MIMEBSON is defined:
MIMEBSON = "application/bson"

@laurentcau laurentcau force-pushed the bson branch 2 times, most recently from 27562a7 to e36d457 Compare June 2, 2025 08:25
@appleboy appleboy modified the milestones: v1.11, v1.12 Jun 21, 2025
@appleboy
Copy link
Member

appleboy commented Oct 3, 2025

@laurentcau Please update the latest code.

go.mod Outdated
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/quic-go/qpack v0.5.1 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
go.mongodb.org/mongo-driver v1.17.2 // indirect
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The latest version is: v1.17.4

@appleboy
Copy link
Member

appleboy commented Oct 4, 2025

image

Lint error.

@laurentcau laurentcau force-pushed the bson branch 2 times, most recently from 8806731 to 168c373 Compare October 6, 2025 08:13
@@ -1,5 +1,9 @@
github.com/bytedance/gopkg v0.1.3 h1:TPBSwH8RsouGCBcMBktLt1AymVo2TVsBVCY4b6TnZ/M=
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

go mod tidy

@codecov
Copy link

codecov bot commented Oct 6, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.82%. Comparing base (3dc1cd6) to head (901533d).
⚠️ Report is 190 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4145      +/-   ##
==========================================
- Coverage   99.21%   98.82%   -0.39%     
==========================================
  Files          42       46       +4     
  Lines        3182     3492     +310     
==========================================
+ Hits         3157     3451     +294     
- Misses         17       30      +13     
- Partials        8       11       +3     
Flag Coverage Δ
?
--ldflags="-checklinkname=0" -tags sonic 98.81% <100.00%> (?)
-tags go_json 98.75% <100.00%> (?)
-tags nomsgpack 98.80% <100.00%> (?)
go-1.18 ?
go-1.19 ?
go-1.20 ?
go-1.21 ?
go-1.24 98.82% <100.00%> (?)
go-1.25 98.82% <100.00%> (?)
macos-latest 98.82% <100.00%> (-0.39%) ⬇️
ubuntu-latest 98.82% <100.00%> (-0.39%) ⬇️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@appleboy
Copy link
Member

appleboy commented Oct 8, 2025

@laurentcau Please help resolve the conflicts.

@appleboy
Copy link
Member

appleboy commented Oct 9, 2025

@laurentcau, sorry, please help to upgrade Go mod files.

@laurentcau laurentcau force-pushed the bson branch 2 times, most recently from 5929e27 to 901533d Compare October 9, 2025 08:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants