response

package
v0.2.10 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2025 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNilInjector = errors.New("nil response injector")
)

Functions

func GetHeadersFromRequestContext

func GetHeadersFromRequestContext(
	ctx context.Context,
) (http.Header, error)

GetHeadersFromRequestContext tries to get the response headers from the context

Parameters:

- ctx: The context to get the response headers from

Returns:

- http.Header: The response headers - error: If there was an error getting the response headers

func SetHeadersFromCallInfo added in v0.2.8

func SetHeadersFromCallInfo(
	headers http.Header,
	callInfo connect.CallInfo,
)

SetHeadersFromCallInfo injects the headers from the call info to the headers

Parameters:

- respHeader: The headers to inject the headers to - callInfo: The call info to get the headers from

Types

type DefaultInterceptor

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

DefaultInterceptor is the default tokens response headers interceptor

func NewDefaultInterceptor

func NewDefaultInterceptor(
	options *Options,
) *DefaultInterceptor

NewDefaultInterceptor creates a new default tokens response headers interceptor

Parameters:

  • options: the options for the interceptor

Returns:

- *DefaultInterceptor: the default tokens response headers interceptor

func (DefaultInterceptor) InjectHeadersFromCallInfo

func (i DefaultInterceptor) InjectHeadersFromCallInfo(
	ctx context.Context,
	callInfo connect.CallInfo,
) error

InjectHeadersFromCallInfo injects headers from the call info into the response headers

Parameters:

- ctx: the context - callInfo: the call info

Returns:

- error: if there was an error injecting the headers

func (DefaultInterceptor) InjectTokens added in v0.2.2

func (i DefaultInterceptor) InjectTokens(
	ctx context.Context,
	refreshToken, accessToken string,
) error

InjectTokens injects the access and refresh tokens into the response headers

Parameters:

- ctx: the context - refreshToken: the refresh token - accessToken: the access token

Returns:

- error: if there was an error injecting the tokens into the response headers

func (DefaultInterceptor) InjectTokensFromContext added in v0.2.2

func (i DefaultInterceptor) InjectTokensFromContext(
	ctx context.Context,
) error

InjectTokensFromContext injects the refresh and access tokens from the context into the response headers

Parameters:

  • ctx: the context

Returns:

- error: if there was an error injecting the tokens into the response headers

type Injector

type Injector interface {
	InjectTokens(
		ctx context.Context,
		refreshToken,
		accessToken string,
	) error
	InjectTokensFromContext(
		ctx context.Context,
	) error
	InjectHeadersFromCallInfo(
		ctx context.Context,
		callInfo connect.CallInfo,
	) error
}

Injector is used to inject headers into the response headers

type Options

type Options struct {
	// CustomRefreshTokenName is the custom refresh token name to use in the response headers
	CustomRefreshTokenName *string

	// CustomAccessTokenName is the custom access token name to use in the response headers
	CustomAccessTokenName *string

	// CookieAttributes is a map of cookie attributes to use for the tokens
	CookieAttributes []http.Cookie
}

Options are the options for the tokens response headers interceptor

Jump to

Keyboard shortcuts

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