Help us shape the future of Go! Take the 2026 Go Developer Survey

message

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: Apache-2.0 Imports: 19 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, 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. A plan that failed to resolve reports the same error for every response, but still compares HTTP status.

func (ResponsePlan) Decode

func (p ResponsePlan) Decode(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 they are not.

Jump to

Keyboard shortcuts

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