Migrate utility layer to http::Request/Response and add compat adapter (PR 11)#620
Closed
Migrate utility layer to http::Request/Response and add compat adapter (PR 11)#620
Conversation
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
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
http_util,auth,cookies, andedge_cookiefromfastly::Request/Responsetohttp::Request<Body>/http::Response<Body>, making these modules platform-agnosticcompat.rsas a temporary bridge module so handler/integration layer code (still holdingfastly::Request) can call the migrated utilities without a full call-stack conversion in this PR — all bridge functions are marked// TODO(PR15): RemoveTlsProtocol,TlsCipher, andClientIpExtrequest extension types so the Fastly adapter can inject platform-specific TLS and client-IP data intohttp::Requestextensions at the boundary, with no Fastly SDK imports in the utility layerChanges
src/compat.rs(new)from_fastly_request_ref,from_fastly_request,to_fastly_request,from_fastly_response,to_fastly_response, and*_fastlyshims for each utility functionsrc/http_util.rshttp::Request<Body>/http::Response<Body>;SPOOFABLE_FORWARDED_HEADERSmadepub(crate)src/auth.rsenforce_basic_authsignaturesrc/cookies.rshandle_request_cookies,forward_cookie_header,set_ec_cookie,expire_ec_cookiesrc/edge_cookie.rsget_ec_id,get_or_generate_ec_id,generate_ec_id; readsClientIpExtfrom extensionssrc/lib.rspub mod compatsrc/auction/endpoints.rscompat::*_fastlysrc/auction/formats.rscompat::generate_ec_id_fastlysrc/integrations/lockr.rscompat::*_fastlysrc/integrations/permutive.rscompat::copy_custom_headers_fastlysrc/integrations/prebid.rscompat::*_fastlysrc/integrations/registry.rscompat::*_fastlysrc/integrations/testlight.rscompat::get_ec_id_fastlysrc/proxy.rscompat::get_ec_id_fastlysrc/publisher.rscompat::*_fastlyadapter-fastly/src/main.rssanitize_forwarded_headersandenforce_basic_authupdated tocompat::*_fastlyTest plan
cargo test --workspacecargo clippy --workspace --all-targets --all-features -- -D warningscargo fmt --all -- --checkcd crates/js/lib && npx vitest runcd crates/js/lib && npm run formatcd docs && npm run formatcargo build --package trusted-server-adapter-fastly --release --target wasm32-wasip1fastly compute serveChecklist
unwrap()in production code — useexpect("should ...")tracingmacros (notprintln!)