Skip to content
Myr

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 file

Take 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 back
1// 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)12

chore: add some annotations (#1544)田欧before adoptiond510595

line 13why, one step back
13// MsgPack contains the given interface object.

style: remove optional return (#1036)田欧before adoption7b50818

lines 14–19why, one step back
14type MsgPack struct {
15 Data interface{}16}1718var msgpackContentType = []string{"application/msgpack; charset=utf-8"}19

chore: add some annotations (#1544)田欧before adoptiond510595

line 20why, one step back
20// WriteContentType (MsgPack) writes MsgPack ContentType.

style: remove optional return (#1036)田欧before adoption7b50818

lines 21–24why, one step back
21func (r MsgPack) WriteContentType(w http.ResponseWriter) {
22 writeContentType(w, msgpackContentType)23}24

chore: add some annotations (#1544)田欧before adoptiond510595

line 25why, one step back
25// 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 back
26func (r MsgPack) Render(w http.ResponseWriter) error {
27 return WriteMsgPack(w, r.Data)28}29

chore: add some annotations (#1544)田欧before adoptiond510595

line 30why, one step back
30// WriteMsgPack writes MsgPack ContentType and encodes the given interface object.

style: remove optional return (#1036)田欧before adoption7b50818

lines 31–32why, one step back
31func WriteMsgPack(w http.ResponseWriter, obj interface{}) error {
32 writeContentType(w, msgpackContentType)

render: update msgpack usage (#1498)田欧before adoption32b58e0

lines 33–34why, one step back
33 var mh codec.MsgpackHandle
34 return codec.NewEncoder(w, &mh).Encode(obj)

style: remove optional return (#1036)田欧before adoption7b50818

line 35why, one step back
35}