proxy

package
v0.0.0-...-fb79b61 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthHeaders

type AuthHeaders interface {
	AuthHeaders(context.Context, *http.Request) (map[string]string, error)
}

AuthHeaders translates a request into headers to pass on to the remote server Errors which implement gRPC status will be returned to the client as HTTP errors, otherwise 500 with a log line

type AuthHeadersFunc

type AuthHeadersFunc func(context.Context, *http.Request) (map[string]string, error)

func (AuthHeadersFunc) AuthHeaders

func (f AuthHeadersFunc) AuthHeaders(ctx context.Context, r *http.Request) (map[string]string, error)

type Codec

type Codec interface {
	ToProto(body []byte, msg protoreflect.Message) error
	FromProto(msg protoreflect.Message) ([]byte, error)
}

type GRPCMethodConfig

type GRPCMethodConfig struct {
	AuthHeaders AuthHeaders
	Invoker     Invoker
	Method      protoreflect.MethodDescriptor
}

type Invoker

type Invoker interface {
	// Invoke is desined for gRPC ClientConn.Invoke, the two interfaces should
	// be protos...
	Invoke(context.Context, string, interface{}, interface{}, ...grpc.CallOption) error
}

type Router

type Router struct {
	ForwardResponseHeaders map[string]bool
	ForwardRequestHeaders  map[string]bool
	Codec                  Codec
	// contains filtered or unexported fields
}

func NewRouter

func NewRouter(codec Codec) *Router

func (*Router) HealthCheck

func (rr *Router) HealthCheck(path string, callback func() error)

func (*Router) RegisterGRPCMethod

func (rr *Router) RegisterGRPCMethod(ctx context.Context, config GRPCMethodConfig) error

func (*Router) RegisterService

func (rr *Router) RegisterService(ctx context.Context, ss protoreflect.ServiceDescriptor, conn Invoker) error

RegisterService calls RegisterGRPCMethod on all methods of the service with default config.

func (*Router) ServeHTTP

func (rr *Router) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*Router) SetNotFoundHandler

func (rr *Router) SetNotFoundHandler(handler http.Handler)

func (*Router) StaticJSON

func (rr *Router) StaticJSON(path string, document interface{}) error

func (*Router) Use

func (rr *Router) Use(middleware func(http.Handler) http.Handler)

Jump to

Keyboard shortcuts

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