runtime

package
v1.1.68 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 24, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHTTPBodyJsonMarshaler

func NewHTTPBodyJsonMarshaler(options ...JSONPbOption) runtime.Marshaler

func NewHTTPBodyProtoMarshaler

func NewHTTPBodyProtoMarshaler() runtime.Marshaler

func NewHTTPBodyYamlMarshaler

func NewHTTPBodyYamlMarshaler() 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

type HTTPBodyPbOption

type HTTPBodyPbOption interface {
	// contains filtered or unexported methods
}

A HTTPBodyPbOption sets options.

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

type JSONPb struct {
	runtime.JSONPb
}

json -> proto|interface{}

func (*JSONPb) ApplyOptions

func (o *JSONPb) ApplyOptions(options ...JSONPbOption) *JSONPb

func (*JSONPb) Marshal

func (j *JSONPb) Marshal(v interface{}) ([]byte, error)

func (*JSONPb) NewDecoder

func (j *JSONPb) NewDecoder(r io.Reader) runtime.Decoder

NewDecoder returns a Decoder which reads JSON stream from "r".

func (*JSONPb) NewEncoder

func (j *JSONPb) NewEncoder(w io.Writer) runtime.Encoder

NewEncoder returns an Encoder which writes JSON stream into "w".

func (*JSONPb) Unmarshal

func (j *JSONPb) Unmarshal(data []byte, v interface{}) error

Unmarshal unmarshals JSON "data" into "v"

type JSONPbOption

type JSONPbOption interface {
	// contains filtered or unexported methods
}

A JSONPbOption sets options.

func WithDiscardUnknown added in v1.0.168

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 added in v1.0.168

func WithMarshalOptions(option protojson.MarshalOptions) JSONPbOption

func WithOrigName deprecated

func WithOrigName(origName bool) JSONPbOption

Deprecated: Use WithUseProtoNames instead.

func WithUnmarshalAllowPartial added in v1.0.168

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 added in v1.0.168

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 {
	runtime.ProtoMarshaller
}

ProtoMarshaller []byte -> proto|interface{}

func (*ProtoMarshaller) ContentType

func (*ProtoMarshaller) ContentType(_ interface{}) string

ContentType always returns "application/x-protobuf".

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL