Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoDecompressor means that we don't know how to decompress a compressed trailer message. ErrNoDecompressor = errors.New("compressed message encountered, but no decompressor specified") )
Functions ¶
func NewResponseReader ¶
func NewResponseReader(origResp io.ReadCloser, trailers *http.Header, decompressor Decompressor) io.ReadCloser
NewResponseReader returns a response reader that on-the-fly transcodes a gRPC web response into normal gRPC framing. Once the reader has reached EOF, the given trailers (which must be non-nil) are populated.
func NewResponseWriter ¶
func NewResponseWriter(w http.ResponseWriter) (http.ResponseWriter, func() error)
NewResponseWriter returns a response writer that transparently transcodes an gRPC HTTP/2 response to a gRPC-Web response. It can be used as the response writer in the `ServeHTTP` method of a `grpc.Server`. The second return value is a finalization function that takes care of sending the data frame with trailers. It *needs* to be called before the response handler exits successfully (the returned error is simply any error of the underlying response writer passed through).
Types ¶
type Decompressor ¶
type Decompressor func(io.ReadCloser) io.ReadCloser
Decompressor returns a decompressed ReadCloser for a given compressed ReadCloser.