proxy

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2021 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ExceptionHandler added in v0.3.0

type ExceptionHandler func(ctx context.Context, req *httpapi.Request) (handled bool, res *httpapi.Response, err error)

ExceptionHandler is an exception handler function

type Server

type Server struct {
	httpapi.UnimplementedExposedServiceServer
	// contains filtered or unexported fields
}

Server is an HTTP to GRPC proxy server

func NewServer

func NewServer(api, server interface{}, listener *grpc.Server, skipForwardingMetadata bool) (s *Server, err error)

NewServer creates a proxy from HTTP(S) traffic to server using the methods defined by api api should be the Unimplemented<ServiceName> struct compiled by the protobuf. All methods defined on api MUST start with an HTTP method name server MUST implement the same methods as api without the prepended method names, though it may have others without exposing them to HTTP(S) traffic

func (*Server) ProxyStream added in v0.6.0

func (s *Server) ProxyStream(srv httpapi.ExposedService_ProxyStreamServer) (err error)

ProxyStream streams requests and responses in both directions in any order

func (*Server) ProxyUnary added in v0.6.0

func (s *Server) ProxyUnary(ctx context.Context, req *httpapi.Request) (res *httpapi.Response, err error)

ProxyUnary proxies connections through the server

func (*Server) Serve

func (s *Server) Serve(listener net.Listener) (err error)

Serve starts the server

func (*Server) SetExceptionHandler added in v0.3.0

func (s *Server) SetExceptionHandler(handler ExceptionHandler)

SetExceptionHandler sets a function which is called before auto-proxying a request. This function may return handled = false to indicate it did not handle the request and it should be auto-proxied as usual. If handled is returned true, the proxy will assume the request has been handled already and will immediately return res and error

Jump to

Keyboard shortcuts

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