middleware

package
v5.0.0-...-907b390 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: AGPL-3.0 Imports: 39 Imported by: 0

Documentation

Overview

Package servicecontext performs context values read/write, generally through server or client wrappers

Index

Constants

This section is empty.

Variables

View Source
var HandledError = errors.RegisterBaseSentinel(errors.CellsError, "handled")

Functions

func ApplyGRPCIncomingContextModifiers

func ApplyGRPCIncomingContextModifiers(ctx context.Context) (ct context.Context, modified bool, er error)

func ApplyGRPCOutgoingContextModifiers

func ApplyGRPCOutgoingContextModifiers(ctx context.Context) (ct context.Context)

func ApplyHTTPIncomingContextModifiers

func ApplyHTTPIncomingContextModifiers(r *http.Request) (*http.Request, error)

func CellsMetadataIncomingContext

func CellsMetadataIncomingContext(ctx context.Context) (context.Context, bool, error)

func ClientConnIncomingContext

func ClientConnIncomingContext(serverRuntimeContext context.Context) func(ctx context.Context) (context.Context, bool, error)

ClientConnIncomingContext adds the ClientConn to context

func CodeFromHTTPStatus

func CodeFromHTTPStatus(status int) codes.Code

CodeFromHTTPStatus converts an HTTP response status into the corresponding gRPC error code.

func DetectedLanguages

func DetectedLanguages(ctx context.Context) []string

DetectedLanguages reads languages from context

func ErrorFormatStreamClientInterceptor

func ErrorFormatStreamClientInterceptor() grpc.StreamClientInterceptor

func ErrorFormatStreamInterceptor

func ErrorFormatStreamInterceptor(srv interface{}, stream grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error

func ErrorFormatUnaryClientInterceptor

func ErrorFormatUnaryClientInterceptor() grpc.UnaryClientInterceptor

func ErrorFormatUnaryInterceptor

func ErrorFormatUnaryInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error)

func ErrorNoMatchedRouteRetryStreamClientInterceptor

func ErrorNoMatchedRouteRetryStreamClientInterceptor() grpc.StreamClientInterceptor

func ErrorNoMatchedRouteRetryUnaryClientInterceptor

func ErrorNoMatchedRouteRetryUnaryClientInterceptor() grpc.UnaryClientInterceptor

func FromGRPC

func FromGRPC(er error) error

func GrpcClientStatsHandler

func GrpcClientStatsHandler(ctx context.Context) (oo []grpc.DialOption)

func GrpcServerStatsHandler

func GrpcServerStatsHandler(ctx context.Context) (oo []grpc.ServerOption)

func GrpcStreamClientInterceptors

func GrpcStreamClientInterceptors() []grpc.StreamClientInterceptor

GrpcStreamClientInterceptors returns a list of grpc.StreamClientInterceptor

func GrpcStreamServerInterceptors

func GrpcStreamServerInterceptors(rootContext context.Context) []grpc.StreamServerInterceptor

GrpcStreamServerInterceptors returns a list of grpc.StreamServerInterceptor

func GrpcUnaryClientInterceptors

func GrpcUnaryClientInterceptors() []grpc.UnaryClientInterceptor

GrpcUnaryClientInterceptors returns a list of grpc.UnaryClientInterceptor

func GrpcUnaryServerInterceptors

func GrpcUnaryServerInterceptors(rootContext context.Context) []grpc.UnaryServerInterceptor

GrpcUnaryServerInterceptors returns a list of grpc.UnaryServerInterceptor

func HttpContextWrapper

func HttpContextWrapper(svcContext context.Context, h http.Handler) http.Handler

func HttpMetaFromGrpcContext

func HttpMetaFromGrpcContext(ctx context.Context, name string) (string, bool)

HttpMetaFromGrpcContext extracts metadata from context that may have been passed along across services (meta name may be lowered cased)

func HttpRequestInfoToMetadata

func HttpRequestInfoToMetadata(ctx context.Context, req *http.Request) context.Context

HttpRequestInfoToMetadata extracts as much HTTP metadata as possible and stores it in the context as metadata.

func HttpTracingMiddleware

func HttpTracingMiddleware(operation string) func(h http.Handler) http.Handler

HttpTracingMiddleware enabled tracing on HTTP server

func HttpWrapperMeta

func HttpWrapperMeta(h http.Handler) http.Handler

HttpWrapperMeta extracts data from the request and puts it in a context Metadata field.

func HttpWrapperMetrics

func HttpWrapperMetrics(h http.Handler) http.Handler

func MetricsStreamServerInterceptor

func MetricsStreamServerInterceptor() grpc.StreamServerInterceptor

func MetricsUnaryServerInterceptor

func MetricsUnaryServerInterceptor() grpc.UnaryServerInterceptor

func RegisterModifier

func RegisterModifier(m any)

RegisterModifier registers a middleware

func RegisterStatsHandler

func RegisterStatsHandler(h statsHandlers)

func RegistryIncomingContext

func RegistryIncomingContext(serverRuntimeContext context.Context) func(ctx context.Context) (context.Context, bool, error)

RegistryIncomingContext injects the registry in context

func ServiceIncomingContext

func ServiceIncomingContext(serverRuntimeContext context.Context) func(ctx context.Context) (context.Context, bool, error)

func SpanFromContext

func SpanFromContext(ctx context.Context) trace.SpanContext

SpanFromContext reads trace.SpanContext from context

func TargetNameToServiceNameContext

func TargetNameToServiceNameContext(serverRuntimeContext context.Context) func(ctx context.Context) (context.Context, bool, error)

TargetNameToServiceNameContext extracts service name from grpc meta "targetname" and inject it in the context

func ToGRPC

func ToGRPC(er error) error

func WebIncomingContextMiddleware

func WebIncomingContextMiddleware(ct context.Context, endpoint string, serviceContextKey any, srv server.Server, h http.Handler) http.Handler

func WithDetectedLanguages

func WithDetectedLanguages(ctx context.Context, ll []string) context.Context

WithDetectedLanguages passes the languages in context

func WrapErrorHandlerToRoute

func WrapErrorHandlerToRoute(handler func(req *restful.Request, rsp *restful.Response) error) func(req *restful.Request, rsp *restful.Response)

Types

type HttpContextModifier

type HttpContextModifier func(r *http.Request) (*http.Request, error)

type ProtoEntityReaderWriter

type ProtoEntityReaderWriter struct {
	// contains filtered or unexported fields
}

ProtoEntityReaderWriter can read and write values using an encoding such as JSON,XML.

func (*ProtoEntityReaderWriter) Read

func (e *ProtoEntityReaderWriter) Read(req *restful.Request, v interface{}) error

Read a serialized version of the value from the request. The Request may have a decompressing reader. Depends on Content-Encoding.

func (*ProtoEntityReaderWriter) Write

func (e *ProtoEntityReaderWriter) Write(resp *restful.Response, status int, v interface{}) error

Write a serialized version of the value on the response. The Response may have a compressing writer. Depends on Accept-Encoding. status should be a valid Http Status code

type ServiceRetriever

type ServiceRetriever interface {
	ServiceName() string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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