Skip to content

EC middleware integration #538

@aram356

Description

@aram356

Parent epic

#532

Description

Wire EcContext into the request pipeline following the two-phase model. EcContext::read_from_request() runs pre-routing like GeoInfo; generate_if_needed() runs inside organic handlers only.

Scope: main.rs, publisher.rs, endpoints.rs, registry.rs

Acceptance criteria

  • EcContext::read_from_request() called before route match on every request, passed existing geo_info.
  • EC route handlers (/identify, /auction, /api/v1/sync, /admin/*) receive ec_context read-only — never call generate_if_needed(), never mutate.
  • Exception: /sync receives &mut ec_context. May assign fallback consent into ec_context.consent when query-param fallback applies.
  • handle_publisher_request() and integration_registry.handle_proxy() call ec_context.generate_if_needed(settings, &kv) (best-effort, never 500s).
  • ec_finalize_response() runs on every route: withdrawal (cookie delete + tombstone), last_seen (debounced), mismatch reconciliation, new-EC cookie write.
  • route_request() return type changes to Result<(), Error>; response flushed via send_to_client(). #[fastly::main] entrypoint changes to match. Pre-routing errors handled via to_error_response() + send_to_client().
  • handle_auction() signature changes to accept &KvIdentityGraph and &EcContext.
  • Handler refactoring: internal build_consent_context() calls replaced with ec_context.consent. Identity from ec_context.ec_value.
  • cargo test --workspace passes with no regressions.

Spec ref

docs/internal/ssc_technical_spec.md §5, §17

Metadata

Metadata

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions