grpcweb

package
v0.3.11 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
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

View Source
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.

Jump to

Keyboard shortcuts

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