Skip to content

feat: add x-sfc-client header hook#1

Open
andreaanez wants to merge 1 commit into
mainfrom
andrea/x-sfc-client-header
Open

feat: add x-sfc-client header hook#1
andreaanez wants to merge 1 commit into
mainfrom
andrea/x-sfc-client-header

Conversation

@andreaanez
Copy link
Copy Markdown
Contributor

Summary

  • Adds ClientHeaderHook (in internal/hooks/client_header.go) that sets x-sfc-client: speakeasy/go-{version} on every request. Version is parsed from SDKConfiguration.UserAgent at SDKInit time so it stays in sync with the generated SDK version.
  • Adds internal/hooks/registration.go with initHooks(h) registering the new hook for both SDKInit and BeforeRequest chains.
  • Patches internal/hooks/hooks.go New() to call initHooks(h). Speakeasy's regen would emit this same call automatically given the presence of registration.go, but speakeasy run -y is currently blocked by an unrelated spec lint error (duplicate Orders tag in openapi.json), so the call is added manually for now.

Lets server-side middleware identify the SDK explicitly via x-sfc-client instead of parsing the speakeasy-generated User-Agent, whose format Speakeasy can change.

Test plan

  • go build ./... passes
  • go test ./internal/hooks/...TestClientHeaderHook covers speakeasy UA, empty UA, and single-token UA → all pass
  • End-to-end via httptest server: confirmed receiving x-sfc-client: speakeasy/go-0.0.1
  • Reviewer: confirm header value format speakeasy/go-{version} matches what server-side middleware expects

Follow-up

Spec has a duplicate Orders tag (openapi.json lines 8448 and 8496) blocking speakeasy run. Fix upstream in the blueprint repo by giving the order-estimation tag a distinct name (e.g. Order Estimates).

🤖 Generated with Claude Code

Adds ClientHeaderHook that sets x-sfc-client: speakeasy/go-{version} on
every request, with version parsed from SDKConfiguration.UserAgent at
SDKInit time. Lets server-side middleware identify the SDK without
parsing the speakeasy User-Agent (whose format can change).

Wired via internal/hooks/registration.go (initHooks); patched hooks.go
New() to call initHooks(h) since regen is currently blocked by an
unrelated spec lint error (duplicate Orders tag).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@semanticdiff-com
Copy link
Copy Markdown

semanticdiff-com Bot commented May 8, 2026

Review changes with  SemanticDiff

Changed Files
File Status
  internal/hooks/client_header.go  0% smaller
  internal/hooks/client_header_test.go  0% smaller
  internal/hooks/hooks.go  0% smaller
  internal/hooks/registration.go  0% smaller

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