Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var BinaryMediaTypes = []string{
"application/vnd.google.protobuf",
"application/x-protobuf",
}
BinaryMediaTypes is the set of media types that refer to the standard binary Protocol Buffers encoding.
var JSONMediaTypes = []string{
"application/json",
}
JSONMediaTypes is the set of media types that refer to the JSON Protocol Buffers encoding.
var MediaTypes []string
MediaTypes is the set of all media types that can be used for marshaling and unmarshaling Protocol Buffers messages, in order of preference.
var TextMediaTypes = []string{
"text/plain",
}
TextMediaTypes is the set of media types that refer to the text-based Protocol Buffers encoding.
Functions ¶
func FormatMediaType ¶
FormatMediaType formats a complete media type, including parameters, to use when marshaling m.
func IsBinary ¶
IsBinary returns true if the given media-type refers to the standard binary Protocol Buffers encoding.
func IsJSON ¶
IsJSON returns true if the given media-type refers to the JSON Protocol Buffers encoding.
func IsSupportedMediaType ¶
IsSupportedMediaType if the given media-type is supported.
Types ¶
type Marshaler ¶
Marshaler is an interface for marshaling Protocol Buffers messages to a byte slice.
var ( // BinaryMarshaler is a Marshaler that marshals messages to the binary // Protocol Buffers encoding. BinaryMarshaler Marshaler = proto.MarshalOptions{} // JSONMarshaler is a Marshaler that marshals messages to the JSON Protocol // Buffers encoding. JSONMarshaler Marshaler = protojson.MarshalOptions{} // TextMarshaler is a Marshaler that marshals messages to the text-based // Protocol Buffers encoding. TextMarshaler Marshaler = prototext.MarshalOptions{ Multiline: true, Indent: " ", } )
func MarshalerForMediaType ¶
MarshalerForMediaType returns the marshaler to use for the given media type.
type Unmarshaler ¶
Unmarshaler is an interface for unmarshaling Protocol Buffers messages from a byte slice.
var ( // BinaryUnmarshaler is an Unmarshaler that unmarshals messages from the // binary Protocol Buffers encoding. BinaryUnmarshaler Unmarshaler = proto.UnmarshalOptions{} // JSONUnmarshaler is an Unmarshaler that unmarshals messages from the JSON // Protocol Buffers encoding. JSONUnmarshaler Unmarshaler = protojson.UnmarshalOptions{} // TextUnmarshaler is an Unmarshaler that unmarshals messages from the // text-based Protocol Buffers encoding. TextUnmarshaler Unmarshaler = prototext.UnmarshalOptions{} )
func UnmarshalerForMediaType ¶
func UnmarshalerForMediaType(mediaType string) (Unmarshaler, bool)
UnmarshalerForMediaType returns the unmarshaler to use for the given media type.