package httpx import "context" // RequestMetadata is a value snapshot for Logic. It excludes credentials, // query strings, headers and bodies. ClientIP is resolved by App's proxy policy. type RequestMetadata struct{ ClientIP, Method, Route string } type metadataKey struct{} func WithRequestMetadata(ctx context.Context, value RequestMetadata) context.Context { if ctx == nil { ctx = context.Background() } return context.WithValue(ctx, metadataKey{}, value) } func Metadata(ctx context.Context) RequestMetadata { if ctx == nil { return RequestMetadata{} } value, _ := ctx.Value(metadataKey{}).(RequestMetadata) return value }