internal

package
v1.9.3 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2025 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MetadataHeaderPrefix is the http prefix that represents custom metadata
	// parameters to or from a gRPC call.
	MetadataHeaderPrefix = "Grpc-Metadata-"

	// MetadataTrailerPrefix is prepended to gRPC metadata as it is converted to
	// HTTP headers in a response handled by go-zero gateway
	MetadataTrailerPrefix = "Grpc-Trailer-"
)

Variables

This section is empty.

Functions

func GetTimeout

func GetTimeout(header http.Header, defaultTimeout time.Duration) time.Duration

GetTimeout returns the timeout from the header, if not set, returns the default timeout.

func NewRequestParser

func NewRequestParser(r *http.Request, resolver jsonpb.AnyResolver) (grpcurl.RequestParser, error)

NewRequestParser creates a new request parser from the given http.Request and resolver.

func ProcessHeaders

func ProcessHeaders(header http.Header) []string

ProcessHeaders builds the headers for the gateway from HTTP headers. It forwards both custom metadata headers (with Grpc-Metadata- prefix) and OpenTelemetry trace propagation headers (traceparent, tracestate, baggage) to ensure distributed tracing works correctly across the gateway.

Types

type EventHandler added in v1.4.1

type EventHandler struct {
	Status *status.Status
	// contains filtered or unexported fields
}

func NewEventHandler added in v1.4.1

func NewEventHandler(writer io.Writer, resolver jsonpb.AnyResolver) *EventHandler

func (*EventHandler) OnReceiveHeaders added in v1.4.1

func (h *EventHandler) OnReceiveHeaders(md metadata.MD)

func (*EventHandler) OnReceiveResponse added in v1.4.1

func (h *EventHandler) OnReceiveResponse(message proto.Message)

func (*EventHandler) OnReceiveTrailers added in v1.4.1

func (h *EventHandler) OnReceiveTrailers(status *status.Status, md metadata.MD)

func (*EventHandler) OnResolveMethod added in v1.4.1

func (h *EventHandler) OnResolveMethod(_ *desc.MethodDescriptor)

func (*EventHandler) OnSendHeaders added in v1.4.1

func (h *EventHandler) OnSendHeaders(_ metadata.MD)

type Method

type Method struct {
	HttpMethod string
	HttpPath   string
	RpcPath    string
}

func GetMethods

func GetMethods(source grpcurl.DescriptorSource) ([]Method, error)

GetMethods returns all methods of the given grpcurl.DescriptorSource.

Jump to

Keyboard shortcuts

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