Documentation
¶
Index ¶
- func AddCookies(ctx context.Context, cookies []*http.Cookie)
- func GetAPIVersionFromContext(ctx context.Context) (version.APIVersion, bool)
- func GetAllowedMethods(ctx context.Context) ([]string, bool)
- func GetExternalHost(ctx context.Context) (string, bool)
- func GetHandler(ctx context.Context) (string, bool)
- func GetIdempotencyKey(ctx context.Context) (string, bool)
- func GetIdempotencyKeyID(ctx context.Context) (string, bool)
- func GetIdentityFromContext(ctx context.Context) (*types.Identity, bool)
- func GetPathParams(ctx context.Context) (map[string]string, bool)
- func GetPlatformFromContext(ctx context.Context) (constants.PlatformMode, bool)
- func GetPropagatedClientIP(ctx context.Context) (string, bool)
- func GetRequestID(ctx context.Context) (string, bool)
- func GetRequestURL(ctx context.Context) (*url.URL, bool)
- func GetRoutePattern(ctx context.Context) (string, bool)
- func MarkIdempotencyReplayed(ctx context.Context)
- func SetHTTPReplayed(ctx context.Context, replayed bool)
- func ShouldTrace(ctx context.Context) bool
- func WithAPIVersion(ctx context.Context, v version.APIVersion) context.Context
- func WithAllowedMethods(ctx context.Context, methods []string) context.Context
- func WithExternalHost(ctx context.Context, host string) context.Context
- func WithHandler(ctx context.Context, method string) context.Context
- func WithIdempotencyKey(ctx context.Context, key string) context.Context
- func WithIdempotencyKeyID(ctx context.Context, id string) context.Context
- func WithIdempotencyResponseMetadata(ctx context.Context, meta *IdempotencyResponseMetadata) context.Context
- func WithIdentity(ctx context.Context, identity *types.Identity) context.Context
- func WithNoTrace(ctx context.Context) context.Context
- func WithPathParams(ctx context.Context, params map[string]string) context.Context
- func WithPlatform(ctx context.Context, platform constants.PlatformMode) context.Context
- func WithPropagatedClientIP(ctx context.Context, ip string) context.Context
- func WithRequestID(ctx context.Context, id string) context.Context
- func WithRequestLog(ctx context.Context, rl *RequestLog) context.Context
- func WithRequestURL(ctx context.Context, u *url.URL) context.Context
- func WithRoutePattern(ctx context.Context, pattern string) context.Context
- type HTTPResponseMetadata
- type IdempotencyResponseMetadata
- type RequestLog
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddCookies ¶
AddCookies appends cookies to the HTTP response metadata in context.
func GetAPIVersionFromContext ¶
func GetAPIVersionFromContext(ctx context.Context) (version.APIVersion, bool)
GetAPIVersionFromContext retrieves the API version from the context.
func GetAllowedMethods ¶
GetAllowedMethods retrieves the allowed methods from the context.
func GetExternalHost ¶
GetExternalHost retrieves the external request host stored in the context.
func GetHandler ¶
GetHandler retrieves the handler name from the context.
func GetIdempotencyKey ¶
GetIdempotencyKey retrieves the idempotency key from the context.
func GetIdempotencyKeyID ¶
GetIdempotencyKeyID retrieves the idempotency key ID from the context.
func GetIdentityFromContext ¶
GetIdentityFromContext retrieves the identity from the context.
func GetPathParams ¶
GetPathParams retrieves the path parameters from the context.
func GetPlatformFromContext ¶
func GetPlatformFromContext(ctx context.Context) (constants.PlatformMode, bool)
GetPlatformFromContext retrieves the platform mode from the context.
func GetPropagatedClientIP ¶
GetPropagatedClientIP returns the client IP from WithPropagatedClientIP when present and non-empty.
func GetRequestID ¶
GetRequestID retrieves the request ID from the context.
func GetRequestURL ¶
GetRequestURL retrieves the request URL stored in the context.
func GetRoutePattern ¶
GetRoutePattern retrieves the route pattern from the context.
func MarkIdempotencyReplayed ¶
MarkIdempotencyReplayed sets the Replayed flag on the context's idempotency response metadata. Safe to call when no metadata is present.
func SetHTTPReplayed ¶
SetHTTPReplayed sets the Replayed flag on the HTTP response metadata in context.
func ShouldTrace ¶
ShouldTrace returns true if tracing has NOT been suppressed on ctx via WithNoTrace.
func WithAPIVersion ¶
WithAPIVersion returns a child context carrying the given API version.
func WithAllowedMethods ¶
WithAllowedMethods returns a child context carrying the allowed HTTP methods.
func WithExternalHost ¶
WithExternalHost returns a child context carrying the host the browser addressed (from X-Forwarded-Host when the request arrived through a trusted front proxy such as the frontend's custom-domain API rewrite, otherwise the Host header). Auth cookie scoping keys off this value.
func WithHandler ¶
WithHandler returns a child context carrying the given handler name.
func WithIdempotencyKey ¶
WithIdempotencyKey returns a child context carrying the client-supplied idempotency key.
func WithIdempotencyKeyID ¶
WithIdempotencyKeyID returns a child context carrying the idempotency key database ID.
func WithIdempotencyResponseMetadata ¶
func WithIdempotencyResponseMetadata(ctx context.Context, meta *IdempotencyResponseMetadata) context.Context
WithIdempotencyResponseMetadata returns a child context carrying the given metadata pointer.
func WithIdentity ¶
WithIdentity returns a child context carrying the given identity.
func WithNoTrace ¶
WithNoTrace returns a derived context that suppresses span creation for the current call tree.
func WithPathParams ¶
WithPathParams returns a child context carrying the path parameters.
func WithPlatform ¶
WithPlatform returns a child context carrying the given platform mode.
func WithPropagatedClientIP ¶
WithPropagatedClientIP attaches the original HTTP client IP when it was forwarded from the API gateway via gRPC metadata.
func WithRequestID ¶
WithRequestID returns a child context carrying the platform-generated request ID.
func WithRequestLog ¶
func WithRequestLog(ctx context.Context, rl *RequestLog) context.Context
WithRequestLog returns a child context carrying the request log.
func WithRequestURL ¶
WithRequestURL returns a child context carrying the current HTTP request URL. This is used by list presenters to build absolute pagination URLs.
Types ¶
type HTTPResponseMetadata ¶
HTTPResponseMetadata carries response-scoped data (cookies, replay flag) through the request lifecycle via a shared pointer in context.
func GetHTTPResponseMetadata ¶
func GetHTTPResponseMetadata(ctx context.Context) (*HTTPResponseMetadata, bool)
GetHTTPResponseMetadata retrieves the HTTP response metadata from the context.
func WithHTTPResponseMetadata ¶
func WithHTTPResponseMetadata(ctx context.Context) (context.Context, *HTTPResponseMetadata)
WithHTTPResponseMetadata returns a child context carrying a fresh metadata pointer. The pointer is shared so downstream code can mutate it.
type IdempotencyResponseMetadata ¶
type IdempotencyResponseMetadata struct {
Replayed bool
}
IdempotencyResponseMetadata holds mutable, response-scoped flags that allow service-layer code to communicate information back to the transport layer.
func GetIdempotencyResponseMetadata ¶
func GetIdempotencyResponseMetadata(ctx context.Context) (*IdempotencyResponseMetadata, bool)
GetIdempotencyResponseMetadata retrieves the metadata pointer from the context.
type RequestLog ¶
type RequestLog struct {
ID string `json:"id"`
Method string `json:"method"`
Host string `json:"host"`
Path string `json:"path"`
NormalizedRoute string `json:"normalized_route"`
QueryJSON *string `json:"query_json,omitempty"`
StatusCode int `json:"status_code"`
LatencyUs int64 `json:"latency_us"`
AccountID *string `json:"account_id,omitempty"`
TargetAccountID *string `json:"target_account_id,omitempty"`
ActorID *string `json:"actor_id,omitempty"`
ActorType *string `json:"actor_type"`
IdentityType *string `json:"identity_type"`
ClientIP []byte `json:"client_ip"`
ClientIPString *string `json:"client_ip_string"`
UserAgent *string `json:"user_agent"`
Referrer *string `json:"referrer,omitempty"`
ErrorCode *string `json:"error_code,omitempty"`
ErrorMessage *string `json:"error_message,omitempty"`
OccurredAt time.Time `json:"occurred_at"`
IdempotencyKeyID *string `json:"idempotency_key_id"`
InternalErrorMessage *string `json:"internal_error_message,omitempty"`
StackTrace *string `json:"stack_trace,omitempty"`
APIVersion *string `json:"api_version,omitempty"`
TraceID *string `json:"trace_id,omitempty"`
PublicEndpoint bool `json:"public_endpoint"`
BodyJSON *string `json:"body_json,omitempty"`
ResponseJSON *string `json:"response_json,omitempty"`
SkipSave bool `json:"-"`
Hidden bool `json:"-"` // persisted but omitted from the default request-log listing; set from the endpoint's HideFromRequestLog flag
SensitiveResponseFields map[string]bool `json:"-"`
}
RequestLog captures metadata about an HTTP request for logging and auditing.
func GetRequestLog ¶
func GetRequestLog(ctx context.Context) (*RequestLog, bool)
GetRequestLog retrieves the request log from the context.