rpcserver: add GetRequest, remove convenience wrappers #64
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
This PR does two things:
1. Refactor: Idiomatic header access pattern
GetRequest(ctx)to access the full HTTP request from handlersFlashbotsOriginHeaderconstantGetHeader,GetOrigin,WithOrigin)ExtractOriginFromHeaderoptionWhy? The old pattern required modifying go-utils every time we wanted to extract a new header. Want User-Agent? Add
GetUserAgent(). Want another header? Add another function. This is inconvenient and creates unnecessary coupling.The new pattern exposes the request directly - callers use standard
req.Header.Get()to access any header without touching go-utils.2. Feature: User-Agent header support
FlashbotsUserAgentHeaderconstant (X-Flashbots-User-Agent)Why combined? The refactor enables the feature - with
GetRequest(ctx), we can add User-Agent support without adding yet another wrapper function.Related PRs
These PRs depend on this one and should be reviewed together:
Migration
Breaking changes
GetOrigin(),GetHeader(),WithOrigin()removedExtractOriginFromHeaderoption removedImpact: Searched all flashbots repos on GitHub - only protect-rpc, protect-of-api, and mev-share-node-pareto actively use these (all have PRs ready). mev-share-node also references them but is inactive (last push: Jan 2025).
Test plan