httpx

package
v0.4.5 Latest Latest
Warning

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

Go to latest
Published: May 24, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const ContextKeyTrustedSource = "httpx.trusted_source"

ContextKeyTrustedSource is the AppTheory context key used when auth middleware has already captured trusted source provenance for downstream audit/rate-limit code.

Variables

This section is empty.

Functions

func BearerToken

func BearerToken(headers map[string][]string) string

func BindJSON added in v0.4.0

func BindJSON[Req any](ctx *apptheory.Context) (Req, error)

BindJSON uses AppTheory typed request binding for JSON bodies while preserving host's existing ParseJSON request-size and error semantics.

func FirstHeaderValue

func FirstHeaderValue(headers map[string][]string, key string) string

func FirstQueryValue

func FirstQueryValue(query map[string][]string, key string) string

func ParseJSON

func ParseJSON(ctx *apptheory.Context, dest any) error

func SourceIP added in v0.4.0

func SourceIP(ctx *apptheory.Context) string

SourceIP returns the trusted provider-derived source IP convenience value.

func SourceRateLimitIdentifier added in v0.4.0

func SourceRateLimitIdentifier(ctx *apptheory.Context, prefix string) string

SourceRateLimitIdentifier returns a stable rate-limit identifier for callers without a stronger authenticated identity. The identifier is derived only from trusted provider context and falls back to a shared unknown bucket when provider source metadata is unavailable or invalid.

func SourceRateLimitMetadata added in v0.4.0

func SourceRateLimitMetadata(ctx *apptheory.Context) map[string]string

SourceRateLimitMetadata returns safe source metadata for rate-limit audit rows. It intentionally excludes the raw source IP; audit logs may store the raw provider-derived IP, but rate-limit rows use a fingerprint only.

Types

type TrustedSourceInfo added in v0.4.0

type TrustedSourceInfo struct {
	SourceIP string
	Provider string
	Source   string
	Valid    bool
}

TrustedSourceInfo is the sanitized, provider-derived source metadata host uses for audit and rate-limit context. It deliberately comes from AppTheory's SourceProvenance API rather than Forwarded/X-Forwarded-* headers.

func SetTrustedSource added in v0.4.0

func SetTrustedSource(ctx *apptheory.Context) TrustedSourceInfo

SetTrustedSource stores trusted source metadata on the AppTheory context for downstream auth/audit code. The metadata is still derived only from AppTheory's provider context.

func TrustedSource added in v0.4.0

func TrustedSource(ctx *apptheory.Context) TrustedSourceInfo

TrustedSource returns provider-derived source metadata from AppTheory. It does not parse or trust client-controlled forwarding headers.

func TrustedSourceFromContext added in v0.4.0

func TrustedSourceFromContext(ctx *apptheory.Context) TrustedSourceInfo

TrustedSourceFromContext returns previously captured trusted source metadata when present, falling back to AppTheory provider context extraction.

func (TrustedSourceInfo) Fingerprint added in v0.4.0

func (s TrustedSourceInfo) Fingerprint() string

Fingerprint returns a non-secret, deterministic fingerprint for source-IP based rate-limit keys so DynamoDB partition keys do not contain raw IPs.

Jump to

Keyboard shortcuts

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