Skip to content
Myr

bson.go

This file

Path

binding/bson.go

30 lines · 580 bytes · Go

Last changed by

chore(binding): upgrade bson dependency to mongo-driver v2 (#4549)Bob Dubefore adoptionba093d1

History of this file

Take it

feat(render): add bson protocol (#4145)Laurent Caumontbefore adoptiond7776de

lines 1–10why, one step back
1// Copyright 2025 Gin Core Team. All rights reserved.
2// Use of this source code is governed by a MIT style3// license that can be found in the LICENSE file.45package binding67import (8 "io"9 "net/http"10

chore(binding): upgrade bson dependency to mongo-driver v2 (#4549)Bob Dubefore adoptionba093d1

line 11why, one step back
11 "go.mongodb.org/mongo-driver/v2/bson"

feat(render): add bson protocol (#4145)Laurent Caumontbefore adoptiond7776de

lines 12–30why, one step back
12)
1314type bsonBinding struct{}1516func (bsonBinding) Name() string {17 return "bson"18}1920func (b bsonBinding) Bind(req *http.Request, obj any) error {21 buf, err := io.ReadAll(req.Body)22 if err == nil {23 err = b.BindBody(buf, obj)24 }25 return err26}2728func (bsonBinding) BindBody(body []byte, obj any) error {29 return bson.Unmarshal(body, obj)30}