msgpack.go
This file
Path
render/msgpack.go
35 lines · 1015 bytes · Go
Last changed by
chore: add some annotations (#1544)田欧before adoptiond510595
History of this fileTake it
The walk stopped after 200 commits: lines older than 7b50818 point at it.
style: remove optional return (#1036)田欧before adoption7b50818
lines 1–12why, one step back1// Copyright 2017 Manu Martinez-Almeida. 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 render67import (8 "net/http"910 "github.com/ugorji/go/codec"11)12chore: add some annotations (#1544)田欧before adoptiond510595
line 13why, one step back13// MsgPack contains the given interface object.style: remove optional return (#1036)田欧before adoption7b50818
lines 14–19why, one step back14type MsgPack struct {15 Data interface{}16}1718var msgpackContentType = []string{"application/msgpack; charset=utf-8"}19chore: add some annotations (#1544)田欧before adoptiond510595
line 20why, one step back20// WriteContentType (MsgPack) writes MsgPack ContentType.style: remove optional return (#1036)田欧before adoption7b50818
lines 21–24why, one step back21func (r MsgPack) WriteContentType(w http.ResponseWriter) {22 writeContentType(w, msgpackContentType)23}24chore: add some annotations (#1544)田欧before adoptiond510595
line 25why, one step back25// Render (MsgPack) encodes the given interface object and writes data with custom ContentType.style: remove optional return (#1036)田欧before adoption7b50818
lines 26–29why, one step back26func (r MsgPack) Render(w http.ResponseWriter) error {27 return WriteMsgPack(w, r.Data)28}29chore: add some annotations (#1544)田欧before adoptiond510595
line 30why, one step back30// WriteMsgPack writes MsgPack ContentType and encodes the given interface object.style: remove optional return (#1036)田欧before adoption7b50818
lines 31–32why, one step back31func WriteMsgPack(w http.ResponseWriter, obj interface{}) error {32 writeContentType(w, msgpackContentType)render: update msgpack usage (#1498)田欧before adoption32b58e0
lines 33–34why, one step back33 var mh codec.MsgpackHandle34 return codec.NewEncoder(w, &mh).Encode(obj)style: remove optional return (#1036)田欧before adoption7b50818
line 35why, one step back35}