msgpack.go
This file
Path
binding/msgpack.go
37 lines · 768 bytes · Go
Last changed by
chore: support min go version 1.18 (#3511)thinkeroubefore adoption1e1f0b1
History of this fileTake it
The walk stopped after 200 commits: lines older than 9c27053 point at it.
chore: update go.mod and remove space from copyright (#3158)thinkeroubefore adoption4b68a5f
line 1why, one step back1// Copyright 2017 Manu Martinez-Almeida. All rights reserved.byte alignment (#2774)Lancobefore adoption9c27053
lines 2–22why, one step back2// Use of this source code is governed by a MIT style3// license that can be found in the LICENSE file.45//go:build !nomsgpack67package binding89import (10 "bytes"11 "io"12 "net/http"1314 "github.com/ugorji/go/codec"15)1617type msgpackBinding struct{}1819func (msgpackBinding) Name() string {20 return "msgpack"21}22test support go1.18 (#2990)thinkeroubefore adoption2bde107
line 23why, one step back23func (msgpackBinding) Bind(req *http.Request, obj any) error {byte alignment (#2774)Lancobefore adoption9c27053
lines 24–26why, one step back24 return decodeMsgPack(req.Body, obj)25}26test support go1.18 (#2990)thinkeroubefore adoption2bde107
line 27why, one step back27func (msgpackBinding) BindBody(body []byte, obj any) error {byte alignment (#2774)Lancobefore adoption9c27053
lines 28–30why, one step back28 return decodeMsgPack(bytes.NewReader(body), obj)29}30test support go1.18 (#2990)thinkeroubefore adoption2bde107
line 31why, one step back31func decodeMsgPack(r io.Reader, obj any) error {byte alignment (#2774)Lancobefore adoption9c27053
lines 32–37why, one step back32 cdc := new(codec.MsgpackHandle)33 if err := codec.NewDecoder(r, cdc).Decode(&obj); err != nil {34 return err35 }36 return validate(obj)37}