upstream

package
v1.23.3 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package upstream provides utilities for propagating HTTP headers from incoming API requests to outbound toolset HTTP calls.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Handler

func Handler(next http.Handler) http.Handler

Handler wraps an http.Handler to store the incoming HTTP request headers in the request context for downstream toolset forwarding.

func HeadersFromContext

func HeadersFromContext(ctx context.Context) http.Header

HeadersFromContext retrieves upstream HTTP headers from the context. Returns nil if no headers are present.

func NewHeaderTransport

func NewHeaderTransport(base http.RoundTripper, headers map[string]string) http.RoundTripper

NewHeaderTransport wraps an http.RoundTripper to set custom headers on every outbound request. Header values may contain ${headers.NAME} placeholders that are resolved at request time from upstream headers stored in the request context.

func ResolveHeaders

func ResolveHeaders(ctx context.Context, headers map[string]string) map[string]string

ResolveHeaders resolves ${headers.NAME} placeholders in header values using upstream headers from the context. Header names in the placeholder are case-insensitive, matching HTTP header convention.

For example, given the config header:

Authorization: ${headers.Authorization}

and an upstream request with "Authorization: Bearer token", the resolved value will be "Bearer token".

func WithHeaders

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

WithHeaders returns a new context carrying the given HTTP headers.

Types

This section is empty.

Jump to

Keyboard shortcuts

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