gateway

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2019 License: BSD-3-Clause Imports: 10 Imported by: 76

README

Gateway

This repo contains a JSON marshaler suitable for use with the gRPC-Gateway when using gogo/protobuf types.

License

95% of the code is copied from the gRPC-Gateway project, so their license applies.

Documentation

Overview

Package gateway contains marshaling code extracted from github.com/grpc-ecosystem/grpc-gateway/runtime and altered to depend on gogo versions of the proto and jsonpb packages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JSONPb

type JSONPb jsonpb.Marshaler

JSONPb is a runtime.Marshaler which marshals/unmarshals into/from JSON with "github.com/gogo/protobuf/jsonpb".

func (*JSONPb) ContentType

func (*JSONPb) ContentType() string

ContentType always returns "application/json".

func (*JSONPb) Delimiter

func (j *JSONPb) Delimiter() []byte

Delimiter for newline encoded JSON streams.

func (*JSONPb) Marshal

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

Marshal marshals "v" into JSON.

func (*JSONPb) NewDecoder

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

NewDecoder returns a runtime.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". Currently it can only marshal proto.Message.

type Proto

type Proto struct {
	// CustomContentType overrides the default Content-Type
	// of "application/octet-stream".
	CustomContentType string
}

Proto is a runtime.Marshaller which marshals/unmarshals into/from serialize proto bytes

func (*Proto) ContentType

func (p *Proto) ContentType() string

ContentType returns the Content-Type. If CustomContentType is empty, it returns "application/octet-stream".

func (*Proto) Marshal

func (*Proto) Marshal(value interface{}) ([]byte, error)

Marshal marshals "value" into Proto

func (*Proto) NewDecoder

func (p *Proto) NewDecoder(reader io.Reader) runtime.Decoder

NewDecoder returns a Decoder which reads proto stream from "reader".

func (*Proto) NewEncoder

func (p *Proto) NewEncoder(writer io.Writer) runtime.Encoder

NewEncoder returns an Encoder which writes proto stream into "writer".

func (*Proto) Unmarshal

func (*Proto) Unmarshal(data []byte, value interface{}) error

Unmarshal unmarshals proto "data" into "value"

Jump to

Keyboard shortcuts

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