message

package
v0.45.3 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package message decodes HTTP requests and responses into engine messages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Decoder

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

Decoder decodes HTTP payloads as the schema types that scripts declare, or that RPC paths name. It is immutable and safe for concurrent use.

func New

func New(loaded *schema.Schema, set *descriptorpb.FileDescriptorSet, routes *route.Matcher, selector RuleSelector, maxBodyBytes int) (*Decoder, error)

New checks the descriptors against the schema, and every declared request wildcard against its type, before decoding anything.

func (*Decoder) Request

func (d *Decoder) Request(request Request) (protocol.Message, error)

Request decodes a dependency request as its declared type, or as its RPC method's input. An error means the request cannot be identified.

func (*Decoder) Responses

func (d *Decoder) Responses(method, path, rawQuery string, header http.Header) ResponsePlan

Responses decides how ingress compares the responses to one request.

type Request

type Request struct {
	// Method is the HTTP request method.
	Method string
	// Host selects the destination's endpoints. Any port is ignored.
	Host string
	// Path is escaped, as endpoints match it the way ServeMux does.
	Path string
	// RawQuery is the encoded query string without the leading "?".
	RawQuery string
	// Header holds the request headers.
	Header http.Header
	// Body contains at most the configured capture limit.
	Body []byte
	// Overflow reports that Body is truncated and must not be decoded.
	Overflow bool
}

Request is one captured dependency request.

type Response

type Response struct {
	// StatusCode is the backend's HTTP status before RPC-level status handling.
	StatusCode int
	Header     http.Header
	Trailer    http.Header
	// Body contains at most the configured capture limit.
	Body []byte
}

Response is one captured response.

type ResponsePlan

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

ResponsePlan decodes the responses to one ingress request. Its rules select each response's decoding when it arrives; a response none selects uses unruled.

func (ResponsePlan) Decode

func (p ResponsePlan) Decode(ctx context.Context, response Response) protocol.Content

Decode returns a response's comparable content. A response with no message compares by status alone.

func (ResponsePlan) Ignored

func (p ResponsePlan) Ignored() Option[string]

Ignored returns why the responses are never compared, if that is known before any arrives.

type RuleSelector added in v0.43.0

type RuleSelector interface {
	SelectRule(ctx context.Context, rules []javascript.Rule, request javascript.Request, response javascript.Response) (Option[javascript.Rule], error)
}

RuleSelector picks the first of an inbound request's rules that selects a response.

Jump to

Keyboard shortcuts

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