feat: add x-sfc-client header hook#1
Open
andreaanez wants to merge 1 commit into
Open
Conversation
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>
Changed Files
|
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
ClientHeaderHook(ininternal/hooks/client_header.go) that setsx-sfc-client: speakeasy/go-{version}on every request. Version is parsed fromSDKConfiguration.UserAgentatSDKInittime so it stays in sync with the generated SDK version.internal/hooks/registration.gowithinitHooks(h)registering the new hook for both SDKInit and BeforeRequest chains.internal/hooks/hooks.goNew()to callinitHooks(h). Speakeasy's regen would emit this same call automatically given the presence ofregistration.go, butspeakeasy run -yis currently blocked by an unrelated spec lint error (duplicateOrderstag inopenapi.json), so the call is added manually for now.Lets server-side middleware identify the SDK explicitly via
x-sfc-clientinstead of parsing the speakeasy-generatedUser-Agent, whose format Speakeasy can change.Test plan
go build ./...passesgo test ./internal/hooks/...—TestClientHeaderHookcovers speakeasy UA, empty UA, and single-token UA → all passhttptestserver: confirmed receivingx-sfc-client: speakeasy/go-0.0.1speakeasy/go-{version}matches what server-side middleware expectsFollow-up
Spec has a duplicate
Orderstag (openapi.jsonlines 8448 and 8496) blockingspeakeasy run. Fix upstream in the blueprint repo by giving the order-estimation tag a distinct name (e.g.Order Estimates).🤖 Generated with Claude Code