Skip to content

Conversation

@travis-hoover-glean
Copy link
Contributor

Summary

  • Add XGlean beforeRequest hook that sets X-Glean-Exclude-Deprecated-After and X-Glean-Experimental headers
  • Introduce new SDK options WithExcludeDeprecatedAfter and WithIncludeExperimental with corresponding environment variable support
  • Add documentation for testing experimental features and deprecation testing

This is the Go equivalent of gleanwork/api-client-typescript#95

Test plan

  • Verify headers are set correctly when using SDK constructor options
  • Verify headers are set correctly when using environment variables
  • Confirm environment variables take precedence over SDK options
  • Ensure no headers are set when neither option is configured
  • Verify multiple SDK instances maintain separate configurations

Usage Example

import (
	"os"

	apiclientgo "github.com/gleanwork/api-client-go"
)

// Using SDK options
s := apiclientgo.New(
	apiclientgo.WithSecurity(os.Getenv("GLEAN_API_TOKEN")),
	apiclientgo.WithInstance(os.Getenv("GLEAN_INSTANCE")),
	apiclientgo.WithExcludeDeprecatedAfter("2026-10-15"),
	apiclientgo.WithIncludeExperimental(true),
)

// Or using environment variables
// export X_GLEAN_EXCLUDE_DEPRECATED_AFTER="2026-10-15"
// export X_GLEAN_INCLUDE_EXPERIMENTAL="true"

…esting

Add beforeRequest hook that sets X-Glean-Exclude-Deprecated-After and
X-Glean-Experimental headers. Introduce new SDK options WithExcludeDeprecatedAfter
and WithIncludeExperimental with corresponding environment variable support.

- Add XGleanHook implementing beforeRequestHook interface
- Add XGleanConfig for thread-safe configuration storage across SDK instances
- Add WithExcludeDeprecatedAfter and WithIncludeExperimental SDK options
- Environment variables take precedence over SDK options
- Add comprehensive unit tests for hook and SDK options
- Add documentation in README
@travis-hoover-glean travis-hoover-glean requested a review from a team as a code owner January 22, 2026 23:40
@travis-hoover-glean travis-hoover-glean merged commit 3db525d into main Jan 22, 2026
2 checks passed
@travis-hoover-glean travis-hoover-glean deleted the feat/x-glean-headers branch January 22, 2026 23:57
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.

3 participants