Skip to content

Commit

Permalink
fix: Change User-Agent header (#251)
Browse files Browse the repository at this point in the history
Changed the User-Agent header to match the rest of our SDKs. The
pattern is package@version.
  • Loading branch information
gkats authored Feb 16, 2024
1 parent c91ccf4 commit 8821db1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion clerk.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ func (b *defaultBackend) newRequest(ctx context.Context, apiReq *APIRequest) (*h
}
req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", b.Key))
req.Header.Add("Content-Type", "application/json")
req.Header.Add("User-Agent", fmt.Sprintf("Clerk/%s SDK-Go/%s", clerkAPIVersion, sdkVersion))
req.Header.Add("User-Agent", fmt.Sprintf("clerk/clerk-sdk-go@%s", sdkVersion))
req.Header.Add("X-Clerk-SDK", fmt.Sprintf("go/%s", sdkVersion))
req = req.WithContext(ctx)

Expand Down
4 changes: 2 additions & 2 deletions clerk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,10 @@ func TestBackendCall_RequestHeaders(t *testing.T) {
// The client sets the Authorization header correctly.
assert.Equal(t, fmt.Sprintf("Bearer %s", secretKey), r.Header.Get("Authorization"))
// The client sets the User-Agent header.
assert.Equal(t, "Clerk/v1 SDK-Go/v2.0.0", r.Header.Get("User-Agent"))
assert.Equal(t, fmt.Sprintf("clerk/clerk-sdk-go@%s", sdkVersion), r.Header.Get("User-Agent"))
assert.Equal(t, "application/json", r.Header.Get("Content-Type"))
// The client includes a custom header with the SDK version.
assert.Equal(t, "go/v2.0.0", r.Header.Get("X-Clerk-SDK"))
assert.Equal(t, fmt.Sprintf("go/%s", sdkVersion), r.Header.Get("X-Clerk-SDK"))

_, err := w.Write([]byte(`{}`))
require.NoError(t, err)
Expand Down

0 comments on commit 8821db1

Please sign in to comment.