Documentation
¶
Overview ¶
Package requestmeta carries bounded HTTP request metadata across application layers and queue boundaries. It intentionally stores the raw User-Agent and the address resolved by the HTTP framework without parsing either value.
Index ¶
Constants ¶
const ( MaxClientIPBytes = 255 MaxUserAgentBytes = 512 MaxCountryCodeBytes = 8 MaxCountryBytes = 128 MaxRegionBytes = 128 MaxCityBytes = 128 MaxASOrganizationBytes = 256 )
Variables ¶
This section is empty.
Functions ¶
func Bound ¶
Bound truncates an attacker-controlled value by bytes while preserving valid UTF-8. This keeps audit rows and access-log entries bounded.
Types ¶
type Enricher ¶
Enricher adds derived metadata to a request. Implementations must be best-effort: unavailable databases and lookup misses must not fail requests.
type IPMetadata ¶
type IPMetadata struct {
IPCountryCode string `json:"ip_country_code,omitempty"`
IPCountry string `json:"ip_country,omitempty"`
IPRegion string `json:"ip_region,omitempty"`
IPCity string `json:"ip_city,omitempty"`
IPASN uint `json:"ip_asn,omitempty"`
IPASOrganization string `json:"ip_as_organization,omitempty"`
}
IPMetadata is derived locally from MaxMind databases. ASNOrganization is the organization registered for the autonomous system; it is useful for risk analysis but is not guaranteed to be the end user's retail ISP.
type Metadata ¶
type Metadata struct {
ClientIP string `json:"client_ip,omitempty"`
UserAgent string `json:"user_agent,omitempty"`
ActorID int64 `json:"actor_id,omitempty"`
IPMetadata
}
Metadata identifies the request that caused an auditable operation. ActorID is the authenticated caller. It can differ from the object ID of an administrative log entry, which identifies the account being changed.
func From ¶
From returns request metadata when the context originated from HTTP or was explicitly restored from a durable queue payload.