1 // Copyright 2017 Manu Martinez-Almeida. All rights reserved.
2 // Use of this source code is governed by a MIT style
3 // license that can be found in the LICENSE file.
10 "github.com/ugorji/go/codec"
17 var msgpackContentType = []string{"application/msgpack; charset=utf-8"}
19 func (r MsgPack) WriteContentType(w http.ResponseWriter) {
20 writeContentType(w, msgpackContentType)
23 func (r MsgPack) Render(w http.ResponseWriter) error {
24 return WriteMsgPack(w, r.Data)
27 func WriteMsgPack(w http.ResponseWriter, obj interface{}) error {
28 writeContentType(w, msgpackContentType)
29 var h codec.Handle = new(codec.MsgpackHandle)
30 return codec.NewEncoder(w, h).Encode(obj)