msgpack.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. package binder
  2. import (
  3. "github.com/gofiber/utils/v2"
  4. )
  5. // MsgPackBinding is the MsgPack binder for MsgPack request body.
  6. type MsgPackBinding struct {
  7. MsgPackDecoder utils.MsgPackUnmarshal
  8. }
  9. // Name returns the binding name.
  10. func (*MsgPackBinding) Name() string {
  11. return "msgpack"
  12. }
  13. // Bind parses the request body as MsgPack and returns the result.
  14. func (b *MsgPackBinding) Bind(body []byte, out any) error {
  15. return b.MsgPackDecoder(body, out)
  16. }
  17. // Reset resets the MsgPackBinding binder.
  18. func (b *MsgPackBinding) Reset() {
  19. b.MsgPackDecoder = nil
  20. }
  21. // UnimplementedMsgpackMarshal panics to signal that a Msgpack marshaler must
  22. // be configured before MsgPack support can be used.
  23. func UnimplementedMsgpackMarshal(_ any) ([]byte, error) {
  24. panic("Must explicit setup Msgpack, please check docs: https://docs.gofiber.io/next/guide/advance-format#msgpack")
  25. }
  26. // UnimplementedMsgpackUnmarshal panics to signal that a Msgpack unmarshaler
  27. // must be configured before MsgPack support can be used.
  28. func UnimplementedMsgpackUnmarshal(_ []byte, _ any) error {
  29. panic("Must explicit setup Msgpack, please check docs: https://docs.gofiber.io/next/guide/advance-format#msgpack")
  30. }