Documentation ¶
Index ¶
- Constants
- Variables
- func FieldMaskFromRequestBody(r io.Reader, msg proto.Message) (*fieldmask.FieldMask, error)
- func HTTPPathPattern(ctx context.Context) (string, bool)
- func HTTPStatusCode(c codes.Code) int
- func HTTPStatusFromCode(code codes.Code) int
- func NewContextWithServerTransportStream(ctx context.Context, s grpc.ServerStream, method string) context.Context
- func NewServerMetadataContext(ctx context.Context, md ServerMetadata) context.Context
- func PopulateFieldFromPath(msg proto.Message, fieldPathString, value string) error
- func PopulateQueryParameters(msg proto.Message, values url.Values, filter *utilities.DoubleArray) error
- func RPCMethod(ctx context.Context) (string, bool)
- func TransparentHandler(cli grpc.ClientConnInterface, inType, outType protoreflect.MessageType, ...) grpc.StreamHandler
- type AnnotateContextOption
- type Codec
- type CodecJSON
- func (c CodecJSON) Marshal(v interface{}) ([]byte, error)
- func (c CodecJSON) MarshalAppend(b []byte, v interface{}) ([]byte, error)
- func (CodecJSON) Name() string
- func (c CodecJSON) ReadNext(b []byte, r io.Reader, limit int) ([]byte, int, error)
- func (c CodecJSON) Unmarshal(data []byte, v interface{}) error
- func (c CodecJSON) WriteNext(w io.Writer, b []byte) (int, error)
- type CodecProto
- func (c CodecProto) Marshal(v interface{}) ([]byte, error)
- func (c CodecProto) MarshalAppend(b []byte, v interface{}) ([]byte, error)
- func (CodecProto) Name() string
- func (c CodecProto) ReadNext(b []byte, r io.Reader, limit int) ([]byte, int, error)
- func (CodecProto) Unmarshal(data []byte, v interface{}) error
- func (c CodecProto) WriteNext(w io.Writer, b []byte) (int, error)
- type Compressor
- type CompressorGzip
- type DefaultQueryParser
- type Gateway
- type GrpcMethod
- type GrpcMethodHandler
- type GrpcStreamHandler
- type MatchOperation
- type Mux
- func (m *Mux) GetOperation(operation string) *GrpcMethod
- func (m *Mux) GetOperationByName(name string) *GrpcMethod
- func (m *Mux) GetRouteMethods() []RouteOperation
- func (m *Mux) Handler(ctx *fiber.Ctx) error
- func (m *Mux) Invoke(ctx context.Context, method string, args, reply any, opts ...grpc.CallOption) error
- func (m *Mux) MatchOperation(method string, path string) (r result.Result[*MatchOperation])
- func (m *Mux) NewStream(ctx context.Context, desc *grpc.StreamDesc, method string, ...) (grpc.ClientStream, error)
- func (m *Mux) RegisterProxy(sd *grpc.ServiceDesc, proxy lava.GrpcRouter, cli grpc.ClientConnInterface)
- func (m *Mux) RegisterService(sd *grpc.ServiceDesc, ss interface{})
- func (m *Mux) ServeHTTP(writer http.ResponseWriter, request *http.Request)
- func (m *Mux) SetRequestDecoder(name protoreflect.FullName, f func(ctx *fiber.Ctx, msg proto.Message) error)
- func (m *Mux) SetResponseEncoder(name protoreflect.FullName, f func(ctx *fiber.Ctx, msg proto.Message) error)
- func (m *Mux) SetStreamInterceptor(interceptor grpc.StreamServerInterceptor)
- func (m *Mux) SetUnaryInterceptor(interceptor grpc.UnaryServerInterceptor)
- type MuxOption
- func CodecOption(contentType string, c Codec) MuxOption
- func CompressorOption(contentEncoding string, c Compressor) MuxOption
- func ConnectionTimeoutOption(d time.Duration) MuxOption
- func FilesOption(f *protoregistry.Files) MuxOption
- func MaxReceiveMessageSizeOption(s int) MuxOption
- func MaxSendMessageSizeOption(s int) MuxOption
- func TypesOption(t protoregistry.MessageTypeResolver) MuxOption
- type PathFieldVar
- type QueryParameterParser
- type RouteOperation
- type ServerMetadata
- type ServerTransportStream
- func (s *ServerTransportStream) Header() metadata.MD
- func (s *ServerTransportStream) Method() string
- func (s *ServerTransportStream) SendHeader(md metadata.MD) error
- func (s *ServerTransportStream) SetHeader(md metadata.MD) error
- func (s *ServerTransportStream) SetTrailer(md metadata.MD) error
- func (s *ServerTransportStream) Trailer() metadata.MD
- type StreamCodec
- type StreamDirector
Constants ¶
const MetadataHeaderPrefix = "Grpc-Metadata-"
MetadataHeaderPrefix is the http prefix that represents custom metadata parameters to or from a gRPC call.
const MetadataPrefix = "grpcgateway-"
MetadataPrefix is prepended to permanent HTTP header keys (as specified by the IANA) when added to the gRPC context.
const MetadataTrailerPrefix = "Grpc-Trailer-"
MetadataTrailerPrefix is prepended to gRPC metadata as it is converted to HTTP headers in a response handled by grpc-gateway
Variables ¶
var DefaultContextTimeout = 0 * time.Second
DefaultContextTimeout is used for gRPC call context.WithTimeout whenever a Grpc-Timeout inbound header isn't present. If the value is 0 the sent `context` will not have a timeout.
Functions ¶
func FieldMaskFromRequestBody ¶
FieldMaskFromRequestBody creates a FieldMask printing all complete paths from the JSON body.
func HTTPPathPattern ¶ added in v0.2.21
HTTPPathPattern returns the HTTP path pattern string relating to the HTTP handler, if one exists. The format of the returned string is defined by the google.api.http path template type.
func HTTPStatusCode ¶
func HTTPStatusFromCode ¶
HTTPStatusFromCode converts a gRPC error code into the corresponding HTTP response status. See: https://github.com/googleapis/googleapis/blob/master/google/rpc/code.proto
func NewContextWithServerTransportStream ¶ added in v0.2.21
func NewServerMetadataContext ¶ added in v0.2.21
func NewServerMetadataContext(ctx context.Context, md ServerMetadata) context.Context
NewServerMetadataContext creates a new context with ServerMetadata
func PopulateFieldFromPath ¶
PopulateFieldFromPath sets a value in a nested Protobuf structure.
func PopulateQueryParameters ¶
func PopulateQueryParameters(msg proto.Message, values url.Values, filter *utilities.DoubleArray) error
PopulateQueryParameters parses query parameters into "msg" using current query parser
func RPCMethod ¶ added in v0.2.21
RPCMethod returns the method string for the server context. The returned string is in the format of "/package.service/method".
func TransparentHandler ¶ added in v0.2.21
func TransparentHandler(cli grpc.ClientConnInterface, inType, outType protoreflect.MessageType, opts ...grpc.CallOption) grpc.StreamHandler
Types ¶
type AnnotateContextOption ¶ added in v0.2.21
func WithHTTPPathPattern ¶ added in v0.2.21
func WithHTTPPathPattern(pattern string) AnnotateContextOption
type Codec ¶
type Codec interface { encoding.Codec // MarshalAppend appends the marshaled form of v to b and returns the result. MarshalAppend([]byte, interface{}) ([]byte, error) }
Codec defines the interface used to encode and decode messages.
type CodecJSON ¶
type CodecJSON struct { protojson.MarshalOptions protojson.UnmarshalOptions }
CodecJSON is a Codec implementation with protobuf json format.
func (CodecJSON) MarshalAppend ¶
type CodecProto ¶
type CodecProto struct {
proto.MarshalOptions
}
CodecProto is a Codec implementation with protobuf binary format.
func (CodecProto) Marshal ¶
func (c CodecProto) Marshal(v interface{}) ([]byte, error)
func (CodecProto) MarshalAppend ¶
func (c CodecProto) MarshalAppend(b []byte, v interface{}) ([]byte, error)
func (CodecProto) Name ¶
func (CodecProto) Name() string
Name == "proto" overwritting internal proto codec
func (CodecProto) Unmarshal ¶
func (CodecProto) Unmarshal(data []byte, v interface{}) error
type Compressor ¶
type Compressor interface { encoding.Compressor }
Compressor is used to compress and decompress messages. Based on grpc/encoding.
type CompressorGzip ¶
type CompressorGzip struct { Level *int // contains filtered or unexported fields }
CompressorGzip implements the Compressor interface. Based on grpc/encoding/gzip.
func (*CompressorGzip) Compress ¶
func (c *CompressorGzip) Compress(w io.Writer) (io.WriteCloser, error)
Compress implements the Compressor interface.
func (*CompressorGzip) Decompress ¶
Decompress implements the Compressor interface.
type DefaultQueryParser ¶
type DefaultQueryParser struct{}
DefaultQueryParser is a QueryParameterParser which implements the default query parameters parsing behavior.
See https://github.com/grpc-ecosystem/grpc-gateway/issues/2632 for more context.
func (*DefaultQueryParser) Parse ¶
func (*DefaultQueryParser) Parse(msg proto.Message, values url.Values, filter *utilities.DoubleArray) error
Parse populates "values" into "msg". A value is ignored if its key starts with one of the elements in "filter".
type Gateway ¶
type Gateway interface { grpc.ClientConnInterface SetUnaryInterceptor(interceptor grpc.UnaryServerInterceptor) SetStreamInterceptor(interceptor grpc.StreamServerInterceptor) SetRequestDecoder(protoreflect.FullName, func(ctx *fiber.Ctx, msg proto.Message) error) SetResponseEncoder(protoreflect.FullName, func(ctx *fiber.Ctx, msg proto.Message) error) RegisterService(sd *grpc.ServiceDesc, ss interface{}) GetOperation(operation string) *GrpcMethod Handler(*fiber.Ctx) error ServeHTTP(http.ResponseWriter, *http.Request) GetRouteMethods() []RouteOperation }
type GrpcMethod ¶ added in v0.2.21
type GrpcMethod struct { Srv any SrvDesc *grpc.ServiceDesc GrpcMethodDesc *grpc.MethodDesc GrpcStreamDesc *grpc.StreamDesc MethodDesc protoreflect.MethodDescriptor GrpcFullMethod string Meta *lavapbv1.RpcMeta }
type GrpcMethodHandler ¶ added in v0.2.21
type GrpcStreamHandler ¶ added in v0.2.21
type GrpcStreamHandler = grpc.StreamHandler
type MatchOperation ¶ added in v0.2.21
type MatchOperation = routertree.MatchOperation
func GetRouterTarget ¶
func GetRouterTarget(mux *Mux, kind, path string) (*MatchOperation, error)
type Mux ¶
type Mux struct {
// contains filtered or unexported fields
}
func (*Mux) GetOperation ¶ added in v0.2.21
func (m *Mux) GetOperation(operation string) *GrpcMethod
func (*Mux) GetOperationByName ¶ added in v0.2.21
func (m *Mux) GetOperationByName(name string) *GrpcMethod
func (*Mux) GetRouteMethods ¶
func (m *Mux) GetRouteMethods() []RouteOperation
func (*Mux) MatchOperation ¶ added in v0.2.21
func (*Mux) NewStream ¶
func (m *Mux) NewStream(ctx context.Context, desc *grpc.StreamDesc, method string, opts ...grpc.CallOption) (grpc.ClientStream, error)
func (*Mux) RegisterProxy ¶ added in v0.2.21
func (m *Mux) RegisterProxy(sd *grpc.ServiceDesc, proxy lava.GrpcRouter, cli grpc.ClientConnInterface)
func (*Mux) RegisterService ¶
func (m *Mux) RegisterService(sd *grpc.ServiceDesc, ss interface{})
RegisterService satisfies grpc.ServiceRegistrar for generated service code hooks.
func (*Mux) SetRequestDecoder ¶
func (*Mux) SetResponseEncoder ¶
func (*Mux) SetStreamInterceptor ¶
func (m *Mux) SetStreamInterceptor(interceptor grpc.StreamServerInterceptor)
SetStreamInterceptor configures the in-process channel to use the given server interceptor for streaming RPCs when dispatching.
func (*Mux) SetUnaryInterceptor ¶
func (m *Mux) SetUnaryInterceptor(interceptor grpc.UnaryServerInterceptor)
type MuxOption ¶
type MuxOption func(*muxOptions)
MuxOption is an option for a mux.
func CodecOption ¶
CodecOption registers a codec for the given content type.
func CompressorOption ¶
func CompressorOption(contentEncoding string, c Compressor) MuxOption
CompressorOption registers a compressor for the given content encoding.
func ConnectionTimeoutOption ¶
func FilesOption ¶
func FilesOption(f *protoregistry.Files) MuxOption
func TypesOption ¶
func TypesOption(t protoregistry.MessageTypeResolver) MuxOption
type PathFieldVar ¶ added in v0.2.21
type PathFieldVar = routertree.PathFieldVar
type QueryParameterParser ¶
type QueryParameterParser interface {
Parse(msg proto.Message, values url.Values, filter *utilities.DoubleArray) error
}
QueryParameterParser defines interface for all query parameter parsers
type RouteOperation ¶ added in v0.2.21
type RouteOperation = routertree.RouteOperation
type ServerMetadata ¶ added in v0.2.21
ServerMetadata consists of metadata sent from gRPC server.
func ServerMetadataFromContext ¶ added in v0.2.21
func ServerMetadataFromContext(ctx context.Context) (md ServerMetadata, ok bool)
ServerMetadataFromContext returns the ServerMetadata in ctx
type ServerTransportStream ¶ added in v0.2.21
type ServerTransportStream struct {
// contains filtered or unexported fields
}
ServerTransportStream implements grpc.ServerTransportStream. It should only be used by the generated files to support grpc.SendHeader outside of gRPC server use.
func (*ServerTransportStream) Header ¶ added in v0.2.21
func (s *ServerTransportStream) Header() metadata.MD
Header returns the header metadata of the stream.
func (*ServerTransportStream) Method ¶ added in v0.2.21
func (s *ServerTransportStream) Method() string
Method returns the method for the stream.
func (*ServerTransportStream) SendHeader ¶ added in v0.2.21
func (s *ServerTransportStream) SendHeader(md metadata.MD) error
SendHeader sets the header metadata.
func (*ServerTransportStream) SetHeader ¶ added in v0.2.21
func (s *ServerTransportStream) SetHeader(md metadata.MD) error
SetHeader sets the header metadata.
func (*ServerTransportStream) SetTrailer ¶ added in v0.2.21
func (s *ServerTransportStream) SetTrailer(md metadata.MD) error
SetTrailer sets the trailer metadata.
func (*ServerTransportStream) Trailer ¶ added in v0.2.21
func (s *ServerTransportStream) Trailer() metadata.MD
Trailer returns the cached trailer metadata.
type StreamCodec ¶
type StreamCodec interface { Codec // ReadNext returns the size of the next message appended to buf. // ReadNext reads from r until either it has read a complete message or // encountered an error and returns all the data read from r. // The message is contained in dst[:n]. // Excess data read from r is stored in dst[n:]. ReadNext(buf []byte, r io.Reader, limit int) (dst []byte, n int, err error) // WriteNext writes the message to w with a size aware encoding // returning the number of bytes written. WriteNext(w io.Writer, src []byte) (n int, err error) }
StreamCodec is used in streaming RPCs where the message boundaries are determined by the codec.