Documentation ¶
Index ¶
- Variables
- func AddEncodingHeader(ctx context.Context, rw http.ResponseWriter, msg proto.Message) error
- type Marshaler
- func NewFlatMarshaler(singleTypes []reflect.Type, nestedTypes []reflect.Type) *Marshaler
- func NewFlatMarshalerForAssetsV2(singleTypes []reflect.Type, nestedTypes []reflect.Type, ignoreFields []string) *Marshaler
- func NewFlatMarshalerForLocations(singleTypes []reflect.Type, nestedTypes []reflect.Type) *Marshaler
- type SnakeMarshaler
- func (*SnakeMarshaler) ContentType(_ any) string
- func (s *SnakeMarshaler) Marshal(value any) ([]byte, error)
- func (s *SnakeMarshaler) NewDecoder(reader io.Reader) runtime.Decoder
- func (s *SnakeMarshaler) NewEncoder(writer io.Writer) runtime.Encoder
- func (s *SnakeMarshaler) Unmarshal(data []byte, value any) error
- type WrappedDecoder
Constants ¶
This section is empty.
Variables ¶
var ( // ErrUnexpectedType is returned if we got // type we can't handle ErrUnexpectedType = errors.New("unexpected type in structure") // ErrUnexpectedFieldInNestedStruct returned when the nested // struct has unexpected fields (other than string,list and dict) ErrUnexpectedFieldInNestedStruct = errors.New("unexpected field in nested struct") // ErrFailedToDecodeRequest returned when we can't // decode request data into proto.Message ErrFailedToDecodeRequest = errors.New("failed to decode request data") )
Functions ¶
func AddEncodingHeader ¶
AddEncodingHeader adds application/json; charset=utf-8 to response headers
Types ¶
type Marshaler ¶
type Marshaler struct { SingleTypes []reflect.Type NestedTypes []reflect.Type // contains filtered or unexported fields }
Marshaler marshals proto3 oneof into flat json structures
func NewFlatMarshaler ¶
NewFlatMarshaler creates marshaler
func NewFlatMarshalerForAssetsV2 ¶
func NewFlatMarshalerForAssetsV2( singleTypes []reflect.Type, nestedTypes []reflect.Type, ignoreFields []string, ) *Marshaler
NewFlatMarshalerForAssetsV2 creates marshaler for assetsv2
func NewFlatMarshalerForLocations ¶
func NewFlatMarshalerForLocations( singleTypes []reflect.Type, nestedTypes []reflect.Type, ) *Marshaler
NewFlatMarshalerForLocations creates marshaler
func (*Marshaler) ContentType ¶
ContentType returns `application/json` content type.
This is because the Marshaler encodes our proto messages
as json.
func (*Marshaler) NewDecoder ¶
NewDecoder create new WrappedDecoder
func (*Marshaler) NewEncoder ¶
NewEncoder get underlying proto encoder
type SnakeMarshaler ¶
type SnakeMarshaler struct {
// contains filtered or unexported fields
}
func NewSnakeMarshaler ¶
func NewSnakeMarshaler() *SnakeMarshaler
func (*SnakeMarshaler) ContentType ¶
func (*SnakeMarshaler) ContentType(_ any) string
ContentType for a SnakeMarshaler is `application/octet-stream` because
the SnakeMarshaler encodes a protobuf message into json, in the format of a byte slice.
func (*SnakeMarshaler) NewDecoder ¶
func (s *SnakeMarshaler) NewDecoder(reader io.Reader) runtime.Decoder
NewDecoder returns a Decoder which reads proto stream from "reader".
func (*SnakeMarshaler) NewEncoder ¶
func (s *SnakeMarshaler) NewEncoder(writer io.Writer) runtime.Encoder
NewEncoder returns an Encoder which writes proto stream into "writer".
type WrappedDecoder ¶
type WrappedDecoder struct {
// contains filtered or unexported fields
}
WrappedDecoder decoder wrapping json with custom logic handling oneofs
func (*WrappedDecoder) Decode ¶
func (m *WrappedDecoder) Decode(obj any) error
Decode bytes into obj