httpreq

package
v3.7.0 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2026 License: AGPL-3.0 Imports: 8 Imported by: 1

Documentation

Index

Constants

View Source
const (
	LokiEncodingFlagsHeader              = "X-Loki-Response-Encoding-Flags"
	FlagCategorizeLabels    EncodingFlag = "categorize-labels"

	EncodeFlagsDelimiter = ","
)
View Source
const (
	// Headers to ignore in PropagateAllHeadersMiddleware to avoid security or encoding issues.
	AuthorizationHeader  = "Authorization"
	AcceptHeader         = "Accept"
	AcceptEncodingHeader = "Accept-Encoding"
)

Variables

View Source
var (
	// LokiActorPathHeader is the name of the header e.g. used to enqueue requests in hierarchical queues.
	LokiActorPathHeader               = "X-Loki-Actor-Path"
	LokiDisablePipelineWrappersHeader = "X-Loki-Disable-Pipeline-Wrappers"

	// LokiActorPathDelimiter is the delimiter used to serialise the hierarchy of the actor.
	LokiActorPathDelimiter = "|"
)
View Source
var (
	QueryTagsHTTPHeader ctxKey = "X-Query-Tags"

	QueryQueueTimeHTTPHeader ctxKey = "X-Query-Queue-Time"
)

Functions

func AddEncodingFlags

func AddEncodingFlags(req *http.Request, flags EncodingFlags)

func AddEncodingFlagsToContext

func AddEncodingFlagsToContext(ctx context.Context, flags EncodingFlags) context.Context

func ExtractActorPath

func ExtractActorPath(ctx context.Context) []string

ExtractActorPath retrieves the actor path from context.

func ExtractAllHeaders added in v3.7.0

func ExtractAllHeaders(ctx context.Context) http.Header

ExtractAllHeaders retrieves all headers stored in context by PropagateAllHeadersMiddleware.

func ExtractHeader

func ExtractHeader(ctx context.Context, name string) string

ExtractHeader retrieves a single header value from context.

func ExtractQueryMetricsMiddleware

func ExtractQueryMetricsMiddleware() middleware.Interface

func ExtractQueryTagsFromContext added in v3.2.0

func ExtractQueryTagsFromContext(ctx context.Context) string

func ExtractQueryTagsFromHTTP

func ExtractQueryTagsFromHTTP(req *http.Request) string

func ExtractQueryTagsMiddleware

func ExtractQueryTagsMiddleware() middleware.Interface

func InjectActorPath

func InjectActorPath(ctx context.Context, value string) context.Context

InjectActorPath adds the actor path header to context.

func InjectAllHeaders added in v3.7.0

func InjectAllHeaders(ctx context.Context, h http.Header) context.Context

InjectAllHeaders adds all headers from the provided http.Header to the context's header map.

func InjectHeader

func InjectHeader(ctx context.Context, key, value string) context.Context

InjectHeader adds a header to the context's header map.

func InjectQueryTags

func InjectQueryTags(ctx context.Context, tags string) context.Context

func IsLogsDrilldownRequest added in v3.6.0

func IsLogsDrilldownRequest(ctx context.Context) bool

IsLogsDrilldownRequest checks if the request comes from Logs Drilldown by examining the X-Query-Tags header

func PropagateAllHeadersMiddleware added in v3.7.0

func PropagateAllHeadersMiddleware(ignoreList ...string) middleware.Interface

PropagateAllHeadersMiddleware stores all HTTP headers in context for downstream restoration. This is useful when requests go through a codec decode/encode cycle that loses headers. Headers in the ignoreList will not be propagated.

func TagsToKeyValues added in v3.5.0

func TagsToKeyValues(queryTags string) []interface{}

TagsToKeyValues converts QueryTags to form that is easy to log. e.g: `Source=foo,Feature=beta` -> []interface{}{"source", "foo", "feature", "beta"} so that we could log nicely! If queryTags is not in canonical form then its completely ignored (e.g: `key1=value1,key2=value`)

Types

type EncodingFlag

type EncodingFlag string

type EncodingFlags

type EncodingFlags map[EncodingFlag]struct{}

func ExtractEncodingFlags

func ExtractEncodingFlags(req *http.Request) EncodingFlags

func ExtractEncodingFlagsFromCtx

func ExtractEncodingFlagsFromCtx(ctx context.Context) EncodingFlags

func ExtractEncodingFlagsFromProto

func ExtractEncodingFlagsFromProto(req *httpgrpc.HTTPRequest) EncodingFlags

func NewEncodingFlags

func NewEncodingFlags(flags ...EncodingFlag) EncodingFlags

func ParseEncodingFlags

func ParseEncodingFlags(rawFlags string) EncodingFlags

func (*EncodingFlags) Has

func (ef *EncodingFlags) Has(flag EncodingFlag) bool

func (*EncodingFlags) Set

func (ef *EncodingFlags) Set(flags ...EncodingFlag)

func (*EncodingFlags) String

func (ef *EncodingFlags) String() string

Jump to

Keyboard shortcuts

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