Documentation
¶
Overview ¶
Package request provides functionality for handling HTTP Requests including the insertion of configuration options into the request
Index ¶
- func ClearResources(r *http.Request) *http.Request
- func Clone(r *http.Request) (*http.Request, error)
- func CloneWithoutResources(r *http.Request) (*http.Request, error)
- func GetBody(r *http.Request, maxSize ...int64) ([]byte, error)
- func GetBodyReader(r *http.Request) (io.ReadCloser, error)
- func RebindUpstreamShortReadCapture(dst, src context.Context) context.Context
- func SetBody(r *http.Request, body []byte)
- func SetResources(r *http.Request, rsc *Resources) *http.Request
- type Resources
- type UpstreamShortReadCapture
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClearResources ¶
ClearResources removes Resources from the HTTP Request's context
func Clone ¶
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
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 GetBodyReader ¶
func GetBodyReader(r *http.Request) (io.ReadCloser, error)
func RebindUpstreamShortReadCapture ¶ added in v2.0.2
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.
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 ¶
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) Merge ¶
Merge sets the configuration references in the subject resources to the source's
func (*Resources) TracingAttributes ¶ added in v2.0.4
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.