proxy

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2021 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MatchAndStripMethodName

func MatchAndStripMethodName(methodName string) (string, string, bool)

MatchAndStripMethodName returns the method name stripped of its HTTP method and a success flag for that operation

Types

type ExceptionHandler

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 interface{}, listener *grpc.Server) (s *Server, err error)

NewServer creates a proxy from HTTP(S) traffic to a self-connection 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 NewServerNoInterceptorSupport added in v0.10.0

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

NewServerNoInterceptorSupport 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

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

ProxyStream streams requests and responses in both directions in any order

func (*Server) ProxyUnary

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

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

func (*Server) SetSelfConnection added in v0.10.0

func (s *Server) SetSelfConnection(selfConnection interface{}) (err error)

SetSelfConnection sets the self-connection to which requests should be proxied.

Jump to

Keyboard shortcuts

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