http2

package
v0.0.0-...-89602ce Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2020 License: BSD-3-Clause Imports: 9 Imported by: 2

Documentation

Overview

Package http2 contains a minimal implementation of non-TLS http/2 server and client

Package http2 contains a minimal implementation of non-TLS http/2 server and client

Package http2 contains a minimal implementation of non-TLS http/2 server and client

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LogRequestWithVerbosity

func LogRequestWithVerbosity(req *http.Request, verbosity glog.Level)

LogRequestWithVerbosity prints out request when the service binary is run with log_verbosity verbosity

func PercentEncode

func PercentEncode(str string) string

grpc-message has to be percent-encoded, though space can be kept. If the grpc-message is not properly encoded, the whole message will show up as an empty string in the application layer on the client side. i.e. without encoding, errMsg "Failed gwId: 123" will be "" because ':' has to be replaced with '%3A' read here for more info on how grpc encodes on http/2: https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md read here on percent-encoding: https://developer.mozilla.org/en-US/docs/Glossary/percent-encoding

func WriteErrResponse

func WriteErrResponse(w http.ResponseWriter, err *HTTPGrpcError)

WriteErrResponse writes the HTTPGrpcError err into the http.ResponseWriter w. This is used by http2 server, and the server's handler can return after calling this function.

Types

type H2CClient

type H2CClient struct {
	*http.Client
}

H2CClient is a http2 client supports non-SSL only

func NewH2CClient

func NewH2CClient() *H2CClient

NewH2CClient creates a new h2cclient.

type H2CServer

type H2CServer struct {
	*http2.Server
}

H2CServer is a minimal http/2 server supports non-TLS only

func NewH2CServer

func NewH2CServer() *H2CServer

func (*H2CServer) Run

func (server *H2CServer) Run(addr string, handler http.HandlerFunc)

func (*H2CServer) Serve

func (server *H2CServer) Serve(listener net.Listener, handler http.HandlerFunc)

type HTTPGrpcError

type HTTPGrpcError struct {
	Msg            string
	GrpcStatusCode int
	HttpStatusCode int
}

HTTPGrpcError is an error wraps a error message, a grpc status code and a http status code. It implements Error interface.

func NewHTTPGrpcError

func NewHTTPGrpcError(
	msg string,
	grpcStatusCode int,
	httpStatusCode int,
) *HTTPGrpcError

NewHTTPGrpcError creates a new HTTPGrpcError.

func (*HTTPGrpcError) Error

func (err *HTTPGrpcError) Error() string

Error returns HTTPGrpcError as a string

Jump to

Keyboard shortcuts

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