Skip to content
Myr

msgpack.go

This file

Path

binding/msgpack.go

37 lines · 768 bytes · Go

Last changed by

Not known.

History of this file

Take it

The walk stopped after 200 commits: lines older than cf32d2d point at it.

chore(deps): bump github.com/pelletier/go-toml/v2 from 2.2.2 to 2.2.4 (#4212)dependabot[bot]before adoptioncf32d2d

lines 1–37why, 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.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}2223func (msgpackBinding) Bind(req *http.Request, obj any) error {24 return decodeMsgPack(req.Body, obj)25}2627func (msgpackBinding) BindBody(body []byte, obj any) error {28 return decodeMsgPack(bytes.NewReader(body), obj)29}3031func decodeMsgPack(r io.Reader, obj any) error {32 cdc := new(codec.MsgpackHandle)33 if err := codec.NewDecoder(r, cdc).Decode(&obj); err != nil {34 return err35 }36 return validate(obj)37}