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 fileTake it
feat(render): add bson protocol (#4145)Laurent Caumontbefore adoptiond7776de
lines 1–10why, one step back1// 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"10chore(binding): upgrade bson dependency to mongo-driver v2 (#4549)Bob Dubefore adoptionba093d1
line 11why, one step back11 "go.mongodb.org/mongo-driver/v2/bson"feat(render): add bson protocol (#4145)Laurent Caumontbefore adoptiond7776de
lines 12–30why, one step back12)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}