gateway

package
v2.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MetadataHeaderPrefix  = "Appootb-"
	MetadataTrailerPrefix = "Trailer-"
)
View Source
const (
	MIMEJSON = "application/json"
)

Variables

Functions

func IncomingHeaderMatcher

func IncomingHeaderMatcher(key string) (string, bool)

func New

func OutgoingHeaderMatcher

func OutgoingHeaderMatcher(key string) (string, bool)

func ProtoErrorHandler

func ProtoErrorHandler(ctx context.Context, _ *runtime.ServeMux, marshaler runtime.Marshaler,
	w http.ResponseWriter, _ *http.Request, err error)

func StreamErrorHandler

func StreamErrorHandler(_ context.Context, err error) *status.Status

func URLQueryMetadata

func URLQueryMetadata(_ context.Context, r *http.Request) metadata.MD

Types

type JSONMarshal

type JSONMarshal struct{}

func (*JSONMarshal) ContentType

func (j *JSONMarshal) ContentType(_ interface{}) string

ContentType returns the Content-Type which this marshaler is responsible for. The parameter describes the type which is being marshalled, which can sometimes affect the content type returned.

func (*JSONMarshal) Marshal

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

Marshal marshals "v" into byte sequence.

func (*JSONMarshal) NewDecoder

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

NewDecoder returns a Decoder which reads byte sequence from "r".

func (*JSONMarshal) NewEncoder

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

NewEncoder returns an Encoder which writes bytes sequence into "w".

func (*JSONMarshal) Unmarshal

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

Unmarshal unmarshals "data" into "v". "v" must be a pointer value.

type WebStream

type WebStream struct {
	*websocket.Conn
	// contains filtered or unexported fields
}

WebStream implements grpc.ServerStream for websocket connection.

func NewWebsocketStream

func NewWebsocketStream(ctx context.Context, c *websocket.Conn, in, out runtime.Marshaler) *WebStream

func (*WebStream) Context

func (ws *WebStream) Context() context.Context

Context returns the context for this stream.

func (*WebStream) RecvMsg

func (ws *WebStream) RecvMsg(m interface{}) error

RecvMsg blocks until it receives a message into m or the stream is done. It returns io.EOF when the client has performed a CloseSend. On any non-EOF error, the stream is aborted and the error contains the RPC status.

It is safe to have a goroutine calling SendMsg and another goroutine calling RecvMsg on the same stream at the same time, but it is not safe to call RecvMsg on the same stream in different goroutines.

func (*WebStream) SendHeader

func (ws *WebStream) SendHeader(metadata.MD) error

SendHeader sends the header metadata. The provided md and headers set by SetHeader() will be sent. It fails if called multiple times.

func (*WebStream) SendMsg

func (ws *WebStream) SendMsg(m interface{}) error

SendMsg sends a message. On error, SendMsg aborts the stream and the error is returned directly.

SendMsg blocks until:

  • There is sufficient flow control to schedule m with the transport, or
  • The stream is done, or
  • The stream breaks.

SendMsg does not wait until the message is received by the client. An untimely stream closure may result in lost messages.

It is safe to have a goroutine calling SendMsg and another goroutine calling RecvMsg on the same stream at the same time, but it is not safe to call SendMsg on the same stream in different goroutines.

func (*WebStream) SetHeader

func (ws *WebStream) SetHeader(metadata.MD) error

SetHeader sets the header metadata. It may be called multiple times. When call multiple times, all the provided metadata will be merged. All the metadata will be sent out when one of the following happens:

  • ServerStream.SendHeader() is called;
  • The first response is sent out;
  • An RPC status is sent out (error or success).

func (*WebStream) SetTrailer

func (ws *WebStream) SetTrailer(metadata.MD)

SetTrailer sets the trailer metadata which will be sent with the RPC status. When called more than once, all the provided metadata will be merged.

Jump to

Keyboard shortcuts

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