proxy

package
v0.0.0-...-f54cd71 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2025 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppConn

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

	JSONToProto(body []byte, msg protoreflect.Message) error
	QueryToProto(query url.Values, msg protoreflect.Message) error
	ProtoToJSON(msg protoreflect.Message) ([]byte, error)
}

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 GRPCMethodConfig

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

type Router

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

func NewRouter

func NewRouter() *Router

func (*Router) AddMiddleware

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

func (*Router) RegisterGRPCService

func (rr *Router) RegisterGRPCService(ctx context.Context, sd protoreflect.ServiceDescriptor, invoker AppConn) error

func (*Router) ServeHTTP

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

func (*Router) SetGlobalAuth

func (rr *Router) SetGlobalAuth(auth AuthHeaders)

func (*Router) SetHealthCheck

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

func (*Router) SetNotFoundHandler

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

func (*Router) StaticJSON

func (rr *Router) StaticJSON(path string, document any) error

Jump to

Keyboard shortcuts

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