request

package
v2.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2026 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

Package request provides functionality for handling HTTP Requests including the insertion of configuration options into the request

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearResources

func ClearResources(r *http.Request) *http.Request

ClearResources removes Resources from the HTTP Request's context

func Clone

func Clone(r *http.Request) (*http.Request, error)

Clone wraps the builtin Clone to use a deep clone of both the request body reader (when present) and the Trickster context data

func CloneWithoutResources added in v2.0.2

func CloneWithoutResources(r *http.Request) (*http.Request, error)

CloneWithoutResources clones the HTTP request and body reader without cloning Resources. Use this when the caller will immediately set or clear Resources on the result.

func GetBody

func GetBody(r *http.Request, maxSize ...int64) ([]byte, error)

func GetBodyReader

func GetBodyReader(r *http.Request) (io.ReadCloser, error)

func RebindUpstreamShortReadCapture added in v2.0.2

func RebindUpstreamShortReadCapture(dst, src context.Context) context.Context

RebindUpstreamShortReadCapture carries the capture (if any) from src onto dst. Needed when callers rebuild the context from context.Background() and would otherwise drop the binding.

func SetBody

func SetBody(r *http.Request, body []byte)

func SetResources

func SetResources(r *http.Request, rsc *Resources) *http.Request

SetResources will save the Resources collection to the HTTP Request's context

Types

type Resources

type Resources struct {
	sync.Mutex
	BackendOptions    *bo.Options
	PathConfig        *po.Options
	CacheConfig       *co.Options
	CacheClient       cache.Cache
	BackendClient     backends.Backend
	AlternateCacheTTL time.Duration
	TimeRangeQuery    *timeseries.TimeRangeQuery
	Tracer            *tracing.Tracer
	IsMergeMember     bool
	RequestBody       []byte
	MergeFunc         merge.MergeFunc
	MergeRespondFunc  merge.RespondFunc
	TSUnmarshaler     timeseries.UnmarshalerFunc
	TSMarshaler       timeseries.MarshalWriterFunc
	TSTransformer     func(timeseries.Timeseries)
	TS                timeseries.Timeseries
	TSReqestOptions   *timeseries.RequestOptions
	TSMergeStrategy   int
	// TSDedupToleranceNanos is the tolerance window (in nanoseconds) for
	// clustering near-duplicate samples produced by independent fan-out
	// shards. Zero (default) preserves the legacy exact-epoch dedup behavior.
	TSDedupToleranceNanos int64

	Response       *http.Response
	AuthResult     *auth.AuthResult
	AlreadyEncoded bool
	Cancelable     bool
}

Resources is a collection of resources a Trickster request would need to fulfill the client request This is stored in the client request's context for use by request handers.

func GetResources

func GetResources(r *http.Request) *Resources

GetResources will return a casted Resource object from the HTTP Request's context

func NewResources

func NewResources(oo *bo.Options, pathOpts *po.Options, cacheOpts *co.Options,
	c cache.Cache, client backends.Backend, t *tracing.Tracer,
) *Resources

NewResources returns a new Resources collection based on the provided inputs

func (*Resources) Clone

func (r *Resources) Clone() *Resources

Clone returns an exact copy of the subject Resources collection

func (*Resources) Merge

func (r *Resources) Merge(r2 *Resources)

Merge sets the configuration references in the subject resources to the source's

func (*Resources) TracingAttributes added in v2.0.4

func (r *Resources) TracingAttributes() []attribute.KeyValue

TracingAttributes returns low-cardinality request resource attributes for spans.

type UpstreamShortReadCapture added in v2.0.2

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

UpstreamShortReadCapture is a context sidecar that the proxy engine trips when an upstream's body ended before its declared Content-Length. ALB fanout binds one per shard and reads Tripped() to disqualify the slot; non-ALB callers leave it unbound and the proxy path is a no-op.

func GetUpstreamShortReadCapture added in v2.0.2

func GetUpstreamShortReadCapture(ctx context.Context) *UpstreamShortReadCapture

GetUpstreamShortReadCapture returns the capture bound to ctx, or nil.

func WithUpstreamShortReadCapture added in v2.0.2

func WithUpstreamShortReadCapture(ctx context.Context) (context.Context, *UpstreamShortReadCapture)

WithUpstreamShortReadCapture binds a fresh capture to ctx.

func (*UpstreamShortReadCapture) Mark added in v2.0.2

func (c *UpstreamShortReadCapture) Mark()

Mark flags a short read. Safe for concurrent use.

func (*UpstreamShortReadCapture) Tripped added in v2.0.2

func (c *UpstreamShortReadCapture) Tripped() bool

Tripped reports whether Mark was called.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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