Documentation
¶
Overview ¶
Package message decodes HTTP requests and responses into engine messages.
Index ¶
- type Answer
- type Decoder
- func (d *Decoder) Answer(header http.Header, message protocol.Message) (Answer, error)
- func (d *Decoder) Request(request Request) (protocol.Message, error)
- func (d *Decoder) Responses(method, path, rawQuery string, header http.Header) ResponsePlan
- func (d *Decoder) SourceResponse(method string, header http.Header, name schema.TypeRef, response Response) protocol.Content
- type Request
- type Response
- type ResponsePlan
- type RuleSelector
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) Answer ¶ added in v0.55.0
Answer encodes message as the successful response to a dependency request with header, in its wire format: bare protobuf, or HTTP JSON otherwise.
func (*Decoder) Request ¶
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.
func (*Decoder) SourceResponse ¶ added in v0.55.0
func (d *Decoder) SourceResponse(method string, header http.Header, name schema.TypeRef, response Response) protocol.Content
SourceResponse decodes a successful response to a dependency request with method and header as name, for derivations to read. Any other response is a failure.
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 ¶
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.