Documentation ¶
Index ¶
- func NewHTTPBodyJsonMarshaler(options ...JSONPbOption) runtime.Marshaler
- func NewHTTPBodyProtoMarshaler() runtime.Marshaler
- func NewHTTPBodyYamlMarshaler() runtime.Marshaler
- type DecoderWrapper
- type EmptyHTTPBodyPbOption
- type EmptyJSONPbOption
- type HTTPBodyPb
- type HTTPBodyPbOption
- type HTTPBodyPbOptionFunc
- type JSONPb
- type JSONPbOption
- func WithDiscardUnknown(discardUnknown bool) JSONPbOption
- func WithEmitAsInts(enumsAsInts bool) JSONPbOptiondeprecated
- func WithEmitDefaults(emitDefaults bool) JSONPbOptiondeprecated
- func WithEmitUnpopulated(emitUnpopulated bool) JSONPbOption
- func WithIndent(indent string) JSONPbOption
- func WithJSONPb(v JSONPb) JSONPbOption
- func WithMarshalOptions(option protojson.MarshalOptions) JSONPbOption
- func WithOrigName(origName bool) JSONPbOptiondeprecated
- func WithUnmarshalAllowPartial(allowPartial bool) JSONPbOption
- func WithUnmarshalOptions(option protojson.UnmarshalOptions) JSONPbOption
- func WithUseEnumNumbers(useEnumNumbers bool) JSONPbOption
- func WithUseProtoNames(useProtoNames bool) JSONPbOption
- type JSONPbOptionFunc
- type ProtoMarshaller
- func (*ProtoMarshaller) ContentType(_ interface{}) string
- func (marshaller *ProtoMarshaller) Marshal(value interface{}) ([]byte, error)
- func (marshaller *ProtoMarshaller) NewDecoder(reader io.Reader) runtime.Decoder
- func (marshaller *ProtoMarshaller) NewEncoder(writer io.Writer) runtime.Encoder
- func (marshaller *ProtoMarshaller) Unmarshal(data []byte, value interface{}) error
- type YamlDecoderWrapper
- type YamlMarshaller
- func (*YamlMarshaller) ContentType(_ interface{}) string
- func (*YamlMarshaller) Marshal(v interface{}) ([]byte, error)
- func (*YamlMarshaller) NewDecoder(r io.Reader) runtime.Decoder
- func (*YamlMarshaller) NewEncoder(w io.Writer) runtime.Encoder
- func (y *YamlMarshaller) Unmarshal(data []byte, v interface{}) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewHTTPBodyJsonMarshaler ¶
func NewHTTPBodyJsonMarshaler(options ...JSONPbOption) runtime.Marshaler
Types ¶
type DecoderWrapper ¶
type DecoderWrapper struct {
// contains filtered or unexported fields
}
DecoderWrapper is a wrapper around a *json.Decoder that adds support for proto and json to the Decode method.
func (DecoderWrapper) Decode ¶
func (d DecoderWrapper) Decode(v interface{}) error
Decode wraps the embedded decoder's Decode method to support protos using a jsonpb.Unmarshaler.
type EmptyHTTPBodyPbOption ¶
type EmptyHTTPBodyPbOption struct{}
EmptyHTTPBodyPbOption does not alter the configuration. It can be embedded in another structure to build custom options.
This API is EXPERIMENTAL.
type EmptyJSONPbOption ¶
type EmptyJSONPbOption struct{}
EmptyJSONPbOption does not alter the configuration. It can be embedded in another structure to build custom options.
This API is EXPERIMENTAL.
type HTTPBodyPb ¶
type HTTPBodyPb runtime.HTTPBodyMarshaler
HTTPBodyPb is a Marshaler which supports marshaling of a google.api.HttpBody message as the full response body if it is the actual message used as the response. If not, then this will simply fallback to the Marshaler specified as its default Marshaler.
func (*HTTPBodyPb) ApplyOptions ¶
func (o *HTTPBodyPb) ApplyOptions(options ...HTTPBodyPbOption) *HTTPBodyPb
ApplyOptions call apply() for all options one by one
type HTTPBodyPbOption ¶
type HTTPBodyPbOption interface {
// contains filtered or unexported methods
}
A HTTPBodyPbOption sets options.
func WithHTTPBodyPb ¶ added in v1.2.89
func WithHTTPBodyPb(v HTTPBodyPb) HTTPBodyPbOption
WithHTTPBodyPb sets HTTPBodyPb.
func WithMarshaler ¶
func WithMarshaler(marshaler runtime.Marshaler) HTTPBodyPbOption
WithMarshaler Whether to render enum values as integers, as opposed to string values.
type HTTPBodyPbOptionFunc ¶
type HTTPBodyPbOptionFunc func(*HTTPBodyPb)
HTTPBodyPbOptionFunc wraps a function that modifies HTTPBodyPb into an implementation of the HTTPBodyPbOption interface.
type JSONPb ¶
JSONPb is a Marshaler which marshals/unmarshals into/from JSON with the proto.Message by "google.golang.org/protobuf/encoding/protojson" marshaler and [any] by "encoding/json" marshaler. It supports the full functionality of protobuf unlike JSONBuiltin.
The NewDecoder method returns a DecoderWrapper, so the underlying *json.Decoder methods can be used.
func (*JSONPb) ApplyOptions ¶
func (o *JSONPb) ApplyOptions(options ...JSONPbOption) *JSONPb
ApplyOptions call apply() for all options one by one
func (*JSONPb) NewDecoder ¶
NewDecoder returns a Decoder which reads JSON stream from "r".
func (*JSONPb) NewEncoder ¶
NewEncoder returns an Encoder which writes JSON stream into "w".
type JSONPbOption ¶
type JSONPbOption interface {
// contains filtered or unexported methods
}
A JSONPbOption sets options.
func WithDiscardUnknown ¶
func WithDiscardUnknown(discardUnknown bool) JSONPbOption
WithDiscardUnknown If DiscardUnknown is set, unknown fields are ignored.
func WithEmitAsInts
deprecated
func WithEmitAsInts(enumsAsInts bool) JSONPbOption
Deprecated: Use WithUseEnumNumbers instead.
func WithEmitDefaults
deprecated
func WithEmitDefaults(emitDefaults bool) JSONPbOption
Deprecated: Use WithEmitUnpopulated instead.
func WithEmitUnpopulated ¶
func WithEmitUnpopulated(emitUnpopulated bool) JSONPbOption
WithEmitUnpopulated Whether to render fields with zero values.
func WithIndent ¶
func WithIndent(indent string) JSONPbOption
WithIndent A string to indent each level by. The presence of this field will also cause a space to appear between the field separator and value, and for newlines to be appear between fields and array elements.
func WithMarshalOptions ¶
func WithMarshalOptions(option protojson.MarshalOptions) JSONPbOption
func WithOrigName
deprecated
func WithOrigName(origName bool) JSONPbOption
Deprecated: Use WithUseProtoNames instead.
func WithUnmarshalAllowPartial ¶
func WithUnmarshalAllowPartial(allowPartial bool) JSONPbOption
WithUnmarshalAllowPartial If AllowPartial is set, input for messages that will result in missing required fields will not return an error.
func WithUnmarshalOptions ¶
func WithUnmarshalOptions(option protojson.UnmarshalOptions) JSONPbOption
func WithUseEnumNumbers ¶
func WithUseEnumNumbers(useEnumNumbers bool) JSONPbOption
WithUseEnumNumbers Whether to render enum values as integers, as opposed to string values.
func WithUseProtoNames ¶
func WithUseProtoNames(useProtoNames bool) JSONPbOption
WithUseProtoNames Whether to use the original (.proto) name for fields.
type JSONPbOptionFunc ¶
type JSONPbOptionFunc func(*JSONPb)
JSONPbOptionFunc wraps a function that modifies JSONPb into an implementation of the JSONPbOption interface.
type ProtoMarshaller ¶
type ProtoMarshaller struct { proto.MarshalOptions proto.UnmarshalOptions }
ProtoMarshaller []byte -> proto|interface{}
func (*ProtoMarshaller) ContentType ¶
func (*ProtoMarshaller) ContentType(_ interface{}) string
ContentType always returns "application/x-protobuf".
func (*ProtoMarshaller) Marshal ¶ added in v1.2.38
func (marshaller *ProtoMarshaller) Marshal(value interface{}) ([]byte, error)
Marshal marshals "value" into Proto
func (*ProtoMarshaller) NewDecoder ¶ added in v1.2.38
func (marshaller *ProtoMarshaller) NewDecoder(reader io.Reader) runtime.Decoder
NewDecoder returns a Decoder which reads proto stream from "reader".
func (*ProtoMarshaller) NewEncoder ¶ added in v1.2.38
func (marshaller *ProtoMarshaller) NewEncoder(writer io.Writer) runtime.Encoder
NewEncoder returns an Encoder which writes proto stream into "writer".
func (*ProtoMarshaller) Unmarshal ¶ added in v1.2.38
func (marshaller *ProtoMarshaller) Unmarshal(data []byte, value interface{}) error
Unmarshal unmarshals proto "data" into "value"
type YamlDecoderWrapper ¶
type YamlDecoderWrapper struct {
// contains filtered or unexported fields
}
YamlDecoderWrapper is a wrapper around a *json.Decoder that adds support for proto and json to the Decode method.
func (YamlDecoderWrapper) Decode ¶
func (d YamlDecoderWrapper) Decode(v interface{}) error
Decode wraps the embedded decoder's Decode method to support protos using a jsonpb.Unmarshaler.
type YamlMarshaller ¶
type YamlMarshaller struct {
runtime.ProtoMarshaller
}
YamlMarshaller []byte -> proto|interface{}
func (*YamlMarshaller) ContentType ¶
func (*YamlMarshaller) ContentType(_ interface{}) string
ContentType returns the Content-Type which this marshaler is responsible for.
func (*YamlMarshaller) Marshal ¶
func (*YamlMarshaller) Marshal(v interface{}) ([]byte, error)
Marshal marshals "v" into byte sequence.
func (*YamlMarshaller) NewDecoder ¶
func (*YamlMarshaller) NewDecoder(r io.Reader) runtime.Decoder
NewDecoder returns a Decoder which reads byte sequence from "r".
func (*YamlMarshaller) NewEncoder ¶
func (*YamlMarshaller) NewEncoder(w io.Writer) runtime.Encoder
NewEncoder returns an Encoder which writes bytes sequence into "w".
func (*YamlMarshaller) Unmarshal ¶
func (y *YamlMarshaller) Unmarshal(data []byte, v interface{}) error
Unmarshal unmarshal "data" into "v". "v" must be a pointer value.