File: codecs.go

package info (click to toggle)
golang-github-mesos-mesos-go 0.0.6%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 11,724 kB
  • sloc: makefile: 163
file content (33 lines) | stat: -rw-r--r-- 946 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package codecs

import (
	"github.com/mesos/mesos-go/api/v1/lib/encoding"
	"github.com/mesos/mesos-go/api/v1/lib/encoding/json"
	"github.com/mesos/mesos-go/api/v1/lib/encoding/proto"
)

const (
	// MediaTypeProtobuf is the Protobuf serialization format media type.
	MediaTypeProtobuf = encoding.MediaType("application/x-protobuf")
	// MediaTypeJSON is the JSON serialiation format media type.
	MediaTypeJSON = encoding.MediaType("application/json")

	NameProtobuf = "protobuf"
	NameJSON     = "json"
)

// ByMediaType are pre-configured default Codecs, ready to use OOTB
var ByMediaType = map[encoding.MediaType]encoding.Codec{
	MediaTypeProtobuf: encoding.Codec{
		Name:       NameProtobuf,
		Type:       MediaTypeProtobuf,
		NewEncoder: proto.NewEncoder,
		NewDecoder: proto.NewDecoder,
	},
	MediaTypeJSON: encoding.Codec{
		Name:       NameJSON,
		Type:       MediaTypeJSON,
		NewEncoder: json.NewEncoder,
		NewDecoder: json.NewDecoder,
	},
}