Skip to content

rpcserver: add GetRequest, remove convenience wrappers#64

Merged
odysseus0 merged 1 commit intomainfrom
refactor/generic-header-access
Jan 22, 2026
Merged

rpcserver: add GetRequest, remove convenience wrappers#64
odysseus0 merged 1 commit intomainfrom
refactor/generic-header-access

Conversation

@odysseus0
Copy link
Contributor

@odysseus0 odysseus0 commented Jan 22, 2026

Summary

This PR does two things:

1. Refactor: Idiomatic header access pattern

  • Add GetRequest(ctx) to access the full HTTP request from handlers
  • Export FlashbotsOriginHeader constant
  • Remove convenience wrappers (GetHeader, GetOrigin, WithOrigin)
  • Remove ExtractOriginFromHeader option

Why? 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

  • Add FlashbotsUserAgentHeader constant (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:

  • flashbots/protect-rpc#36
  • flashbots/protect-of-api#13
  • flashbots/mev-share-node-pareto#93

Migration

// Before
origin := rpcserver.GetOrigin(ctx)

// After
req := rpcserver.GetRequest(ctx)
origin := req.Header.Get(rpcserver.FlashbotsOriginHeader)

Breaking changes

  • GetOrigin(), GetHeader(), WithOrigin() removed
  • ExtractOriginFromHeader option removed

Impact: 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

  • Unit tests pass
  • Searched GitHub for usage across all flashbots repos

@odysseus0 odysseus0 force-pushed the refactor/generic-header-access branch 2 times, most recently from 07e111d to c38df3d Compare January 22, 2026 14:41
- Add GetRequest(ctx) to access the full HTTP request from handlers
- Export FlashbotsOriginHeader constant for callers to use
- Remove GetHeader, GetOrigin, WithOrigin convenience wrappers
- Remove ExtractOriginFromHeader option (moved to app layer)

This follows idiomatic Go patterns - provide raw request access,
let callers use standard req.Header.Get() for header access.

Co-Authored-By: Claude <noreply@anthropic.com>
@odysseus0 odysseus0 force-pushed the refactor/generic-header-access branch from c38df3d to e997be0 Compare January 22, 2026 15:06
@odysseus0 odysseus0 marked this pull request as ready for review January 22, 2026 15:15
@odysseus0 odysseus0 merged commit 84570ad into main Jan 22, 2026
2 checks passed
@odysseus0 odysseus0 deleted the refactor/generic-header-access branch January 22, 2026 15:20
odysseus0 added a commit that referenced this pull request Jan 22, 2026
Allows downstream repos to use the constant instead of string literals.

Follow-up to #64.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
odysseus0 added a commit that referenced this pull request Jan 30, 2026
## Summary
- Restores `GetOrigin`, `WithOrigin`, and `ExtractOriginFromHeader`
removed in #64
- Allows existing code to continue using `GetOrigin(ctx)` pattern

## Why
PR #64 removed these in favor of `GetRequest(ctx)`, but downstream repos
still use the old pattern. This unblocks those repos without requiring
migration.

## Test plan
- [x] `go build ./...`
- [x] `go test ./rpcserver/...`

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
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