Home / File/ msgpack.go — gin Source File

msgpack.go — gin Source File

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

File go ResponseRendering TemplateEngine 1 imports 1 functions 2 classes

Entity Profile

Dependency Diagram

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

Relationship Graph

Source Code

// Copyright 2017 Manu Martinez-Almeida. All rights reserved.
// Use of this source code is governed by a MIT style
// license that can be found in the LICENSE file.

//go:build !nomsgpack

package render

import (
	"net/http"

	"github.com/ugorji/go/codec"
)

// Check interface implemented here to support go build tag nomsgpack.
// See: https://github.com/gin-gonic/gin/pull/1852/
var (
	_ Render = MsgPack{}
)

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

var msgpackContentType = []string{"application/msgpack; charset=utf-8"}

// WriteContentType (MsgPack) writes MsgPack ContentType.
func (r MsgPack) WriteContentType(w http.ResponseWriter) {
	writeContentType(w, msgpackContentType)
}

// Render (MsgPack) encodes the given interface object and writes data with custom ContentType.
func (r MsgPack) Render(w http.ResponseWriter) error {
	return WriteMsgPack(w, r.Data)
}

// WriteMsgPack writes MsgPack ContentType and encodes the given interface object.
func WriteMsgPack(w http.ResponseWriter, obj any) error {
	writeContentType(w, msgpackContentType)
	var mh codec.MsgpackHandle
	return codec.NewEncoder(w, &mh).Encode(obj)
}

Subdomains

Functions

Types

Dependencies

  • http

Frequently Asked Questions

What does msgpack.go do?
msgpack.go is a source file in the gin codebase, written in go. It belongs to the ResponseRendering domain, TemplateEngine subdomain.
What functions are defined in msgpack.go?
msgpack.go defines 1 function(s): WriteMsgPack.
What does msgpack.go depend on?
msgpack.go imports 1 module(s): http.
Where is msgpack.go in the architecture?
msgpack.go is located at render/msgpack.go (domain: ResponseRendering, subdomain: TemplateEngine, directory: render).

Analyze Your Own Codebase

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

Try Supermodel Free