Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GzipMiddleware ¶
GzipMiddleware compresses HTTP responses and decompresses requests.
It handles both request decompression (Content-Encoding: gzip) and response compression (Accept-Encoding: gzip). A compressed request body is decompressed only once the handler reads it.
Requests without compression are handled normally for backward compatibility.
Types ¶
type Admission ¶ added in v0.4.0
type Admission struct {
// Metadata is what the call carries to its backend, in place of any
// request header.
Metadata metadata.MD
// MaxBodySize bounds the body of the call.
MaxBodySize int64
// Release ends the admission once the call is done, however it ended.
Release func()
}
Admission is what an HTTP call is let in with before its body is read.
type Admitter ¶ added in v0.4.0
Admitter lets an HTTP call in before its body is read, or refuses it with a status error.
type Backend ¶ added in v0.4.0
type Backend interface {
GetConnection(ctx context.Context, fullMethodName string) (context.Context, *grpc.ClientConn, error)
}
Backend returns the gRPC connection a call goes over and the context the call runs under, derived from the given one.
type BackendRegistry ¶
BackendRegistry tells the HTTP proxy which services are registered.
A handler asks it before it reads the request body, so a call to an unregistered service costs no read, and asks again once the body is read.
type Option ¶
type Option func(*handlerOptions)
Option configures the HTTPHandler constructor.
func WithTrustedOrigins ¶ added in v0.3.0
WithTrustedOrigins sets the origins whose browser pages may read the handler's responses cross-origin.
A request from any other origin gets no CORS headers, so the browser withholds the response from the calling page.
type TransparentWebGRPCProxy ¶
type TransparentWebGRPCProxy struct {
// contains filtered or unexported fields
}
TransparentWebGRPCProxy is an HTTP handler that translates HTTP requests with binary protobuf payloads to gRPC calls.
func NewHTTPHandler ¶
func NewHTTPHandler(backend Backend, registry BackendRegistry, admitter Admitter, options ...Option) *TransparentWebGRPCProxy
NewHTTPHandler creates a new HTTPHandler that sends every call of a service the registry knows and the admitter lets in to the backend.
func (*TransparentWebGRPCProxy) ServeHTTP ¶
func (m *TransparentWebGRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP handles HTTP requests.