Skip to content

Migrate utility layer to http::Request/Response and add compat adapter (PR 11)#620

Closed
prk-Jr wants to merge 2 commits intomainfrom
feature/edgezero-pr11-utility-layer-migration
Closed

Migrate utility layer to http::Request/Response and add compat adapter (PR 11)#620
prk-Jr wants to merge 2 commits intomainfrom
feature/edgezero-pr11-utility-layer-migration

Conversation

@prk-Jr
Copy link
Copy Markdown
Collaborator

@prk-Jr prk-Jr commented Apr 7, 2026

Summary

  • Migrates http_util, auth, cookies, and edge_cookie from fastly::Request/Response to http::Request<Body> / http::Response<Body>, making these modules platform-agnostic
  • Adds compat.rs as a temporary bridge module so handler/integration layer code (still holding fastly::Request) can call the migrated utilities without a full call-stack conversion in this PR — all bridge functions are marked // TODO(PR15): Remove
  • Introduces TlsProtocol, TlsCipher, and ClientIpExt request extension types so the Fastly adapter can inject platform-specific TLS and client-IP data into http::Request extensions at the boundary, with no Fastly SDK imports in the utility layer

Changes

File Change
src/compat.rs (new) Compat bridge: from_fastly_request_ref, from_fastly_request, to_fastly_request, from_fastly_response, to_fastly_response, and *_fastly shims for each utility function
src/http_util.rs Migrated to http::Request<Body> / http::Response<Body>; SPOOFABLE_FORWARDED_HEADERS made pub(crate)
src/auth.rs Migrated enforce_basic_auth signature
src/cookies.rs Migrated handle_request_cookies, forward_cookie_header, set_ec_cookie, expire_ec_cookie
src/edge_cookie.rs Migrated get_ec_id, get_or_generate_ec_id, generate_ec_id; reads ClientIpExt from extensions
src/lib.rs Added pub mod compat
src/auction/endpoints.rs Call sites updated to compat::*_fastly
src/auction/formats.rs Call site updated to compat::generate_ec_id_fastly
src/integrations/lockr.rs Call sites updated to compat::*_fastly
src/integrations/permutive.rs Call site updated to compat::copy_custom_headers_fastly
src/integrations/prebid.rs Call sites updated to compat::*_fastly
src/integrations/registry.rs Call sites updated to compat::*_fastly
src/integrations/testlight.rs Call site updated to compat::get_ec_id_fastly
src/proxy.rs Call sites updated to compat::get_ec_id_fastly
src/publisher.rs All utility call sites updated to compat::*_fastly
adapter-fastly/src/main.rs sanitize_forwarded_headers and enforce_basic_auth updated to compat::*_fastly

Test plan

  • cargo test --workspace
  • cargo clippy --workspace --all-targets --all-features -- -D warnings
  • cargo fmt --all -- --check
  • JS tests: cd crates/js/lib && npx vitest run
  • JS format: cd crates/js/lib && npm run format
  • Docs format: cd docs && npm run format
  • WASM build: cargo build --package trusted-server-adapter-fastly --release --target wasm32-wasip1
  • Manual testing via fastly compute serve

Checklist

  • Changes follow CLAUDE.md conventions
  • No unwrap() in production code — use expect("should ...")
  • Uses tracing macros (not println!)
  • New code has tests
  • No secrets or credentials committed

Migrates http_util, auth, cookies, and edge_cookie modules from
fastly::Request/Response to http::Request<Body>/http::Response<Body>
as part of the EdgeZero phase 2 platform migration.

Adds compat.rs as a temporary bridge module that lets handler and
integration layer code (which still holds fastly::Request) call into
the migrated utility functions without converting the entire call stack
in this PR. All bridge functions are marked TODO(PR15) for removal once
the handler layer is migrated.

Extension types TlsProtocol, TlsCipher, and ClientIpExt carry
Fastly-specific TLS and client IP data through http::Request extensions
so that detect_request_scheme and generate_ec_id can access them without
a Fastly SDK import in the utility layer.

Closes #492
@prk-Jr prk-Jr self-assigned this Apr 7, 2026
@prk-Jr prk-Jr marked this pull request as draft April 7, 2026 09:58
@prk-Jr prk-Jr changed the title Migrate utility layer to http::Request/Response and add compat adapter Migrate utility layer to http::Request/Response and add compat adapter (PR 11) Apr 7, 2026
Local use statements inside function bodies violate the project's
no-local-imports convention. Move the twelve use statements from
the handler shim functions to module level.

Also adds the PR 11 implementation plan document.
@prk-Jr prk-Jr closed this Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant