Home / File/ bson.go — gin Source File

bson.go — gin Source File

Architecture documentation for bson.go, a go file in the gin codebase. 1 imports, 0 dependents.

File go 1 imports 1 classes

Entity Profile

Dependency Diagram

graph LR
  894f3e93_dea6_3b95_2069_154aef5ce516["bson.go"]
  08248871_dc00_f330_15ef_4a0fbf2bafbb["http"]
  894f3e93_dea6_3b95_2069_154aef5ce516 --> 08248871_dc00_f330_15ef_4a0fbf2bafbb
  style 894f3e93_dea6_3b95_2069_154aef5ce516 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

// 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.

package render

import (
	"net/http"

	"go.mongodb.org/mongo-driver/bson"
)

// BSON contains the given interface object.
type BSON struct {
	Data any
}

var bsonContentType = []string{"application/bson"}

// Render (BSON) marshals the given interface object and writes data with custom ContentType.
func (r BSON) Render(w http.ResponseWriter) error {
	r.WriteContentType(w)

	bytes, err := bson.Marshal(&r.Data)
	if err == nil {
		_, err = w.Write(bytes)
	}
	return err
}

// WriteContentType (BSONBuf) writes BSONBuf ContentType.
func (r BSON) WriteContentType(w http.ResponseWriter) {
	writeContentType(w, bsonContentType)
}

Classes

Types

Dependencies

  • http

Frequently Asked Questions

What does bson.go do?
bson.go is a source file in the gin codebase, written in go.
What does bson.go depend on?
bson.go imports 1 module(s): http.
Where is bson.go in the architecture?
bson.go is located at render/bson.go (directory: render).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free