Documentation
¶
Index ¶
- Constants
- Variables
- func NewJsonReader(body io.ReadCloser) (io.ReadCloser, error)
- func NewJsonWriter(w http.ResponseWriter) (http.ResponseWriter, func() error)
- func NewResponseReader(origResp io.ReadCloser, trailers *http.Header, decompressor Decompressor) io.ReadCloser
- func NewResponseWriter(w http.ResponseWriter) (http.ResponseWriter, func() error)
- type Decompressor
Constants ¶
const ( // GRPCWebOnlyHeader is a header to indicate that the server should always return gRPC-Web // responses, regardless of detected client capabilities. The presence of the header alone // is sufficient, however it is recommended that a client chooses "true" as the only value // whenver the header is used. GRPCWebOnlyHeader = `Grpc-Web-Only` )
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 NewJsonReader ¶
func NewJsonReader(body io.ReadCloser) (io.ReadCloser, error)
func NewJsonWriter ¶
func NewJsonWriter(w http.ResponseWriter) (http.ResponseWriter, func() error)
NewJsonWriter 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).
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.