hooks

package
v0.11.36 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 23, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetXGleanConfig added in v0.11.21

func SetXGleanConfig(sdk any, config XGleanConfig)

SetXGleanConfig stores the X-Glean configuration for a given SDK instance.

Types

type AfterErrorContext

type AfterErrorContext struct {
	HookContext
}

type AfterSuccessContext

type AfterSuccessContext struct {
	HookContext
}

type AgentFileUploadHook added in v0.11.13

type AgentFileUploadHook struct{}

func (*AgentFileUploadHook) AfterError added in v0.11.13

func (h *AgentFileUploadHook) AfterError(hookCtx AfterErrorContext, res *http.Response, err error) (*http.Response, error)

type BeforeRequestContext

type BeforeRequestContext struct {
	HookContext
}

type FailEarly

type FailEarly struct {
	Cause error
}

func (*FailEarly) Error

func (f *FailEarly) Error() string

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

HTTPClient provides an interface for supplying the SDK with a custom HTTP client

type HookContext

type HookContext struct {
	SDK              any
	SDKConfiguration config.SDKConfiguration
	BaseURL          string
	Context          context.Context
	OperationID      string
	OAuth2Scopes     []string
	SecuritySource   func(context.Context) (interface{}, error)
}

type Hooks

type Hooks struct {
	// contains filtered or unexported fields
}

func New

func New() *Hooks

func (*Hooks) AfterError

func (h *Hooks) AfterError(hookCtx AfterErrorContext, res *http.Response, err error) (*http.Response, error)

func (*Hooks) AfterSuccess

func (h *Hooks) AfterSuccess(hookCtx AfterSuccessContext, res *http.Response) (*http.Response, error)

func (*Hooks) BeforeRequest

func (h *Hooks) BeforeRequest(hookCtx BeforeRequestContext, req *http.Request) (*http.Request, error)

func (*Hooks) SDKInit

func (h *Hooks) SDKInit(baseURL string, client HTTPClient) (string, HTTPClient)

type ServerURLNormalizerHook added in v0.11.29

type ServerURLNormalizerHook struct{}

ServerURLNormalizerHook normalizes server URLs by prepending https:// if no scheme is provided.

func (*ServerURLNormalizerHook) SDKInit added in v0.11.29

func (h *ServerURLNormalizerHook) SDKInit(baseURL string, client HTTPClient) (string, HTTPClient)

type XGleanConfig added in v0.11.21

type XGleanConfig struct {
	// ExcludeDeprecatedAfter excludes API endpoints that will be deprecated after this date.
	// Format: YYYY-MM-DD (e.g., "2026-10-15")
	ExcludeDeprecatedAfter string

	// IncludeExperimental enables experimental API features when true.
	IncludeExperimental bool
}

XGleanConfig holds configuration for X-Glean headers. This is used to pass configuration from SDK options to the hook.

func GetXGleanConfig added in v0.11.21

func GetXGleanConfig(sdk any) XGleanConfig

GetXGleanConfig retrieves the X-Glean configuration for a given SDK instance. Returns an empty config if none is set.

type XGleanHook added in v0.11.21

type XGleanHook struct{}

XGleanHook is a beforeRequest hook that sets X-Glean headers for experimental features and deprecation testing.

func (*XGleanHook) BeforeRequest added in v0.11.21

func (h *XGleanHook) BeforeRequest(hookCtx BeforeRequestContext, req *http.Request) (*http.Request, error)

BeforeRequest sets the X-Glean-Exclude-Deprecated-After and X-Glean-Experimental headers based on environment variables or SDK configuration. Environment variables take precedence over SDK options.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL