Skip to content
Myr

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 file

Take 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 back
1// Copyright 2017 Manu Martinez-Almeida. All rights reserved.

byte alignment (#2774)Lancobefore adoption9c27053

lines 2–22why, one step back
2// Use of this source code is governed by a MIT style
3// 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}22

test support go1.18 (#2990)thinkeroubefore adoption2bde107

line 23why, one step back
23func (msgpackBinding) Bind(req *http.Request, obj any) error {

byte alignment (#2774)Lancobefore adoption9c27053

lines 24–26why, one step back
24 return decodeMsgPack(req.Body, obj)
25}26

test support go1.18 (#2990)thinkeroubefore adoption2bde107

line 27why, one step back
27func (msgpackBinding) BindBody(body []byte, obj any) error {

byte alignment (#2774)Lancobefore adoption9c27053

lines 28–30why, one step back
28 return decodeMsgPack(bytes.NewReader(body), obj)
29}30

test support go1.18 (#2990)thinkeroubefore adoption2bde107

line 31why, one step back
31func decodeMsgPack(r io.Reader, obj any) error {

byte alignment (#2774)Lancobefore adoption9c27053

lines 32–37why, one step back
32 cdc := new(codec.MsgpackHandle)
33 if err := codec.NewDecoder(r, cdc).Decode(&obj); err != nil {34 return err35 }36 return validate(obj)37}