response

package
v0.2.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

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

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) InjectAccessAndRefreshTokens

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

InjectAccessAndRefreshToken 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) 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) InjectRefreshAndAccessTokensFromContext

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

InjectRefreshAndAccessTokensFromContext 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 {
	InjectAccessAndRefreshTokens(
		ctx context.Context,
		refreshToken,
		accessToken string,
	) error
	InjectAccessAndRefreshTokensFromContext(
		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 map[string]http.Cookie

	// CookieRefreshTokenDuration is the duration to set for the refresh token cookie
	CookieRefreshTokenDuration *time.Duration

	// CookieAccessTokenDuration is the duration to set for the access token cookie
	CookieAccessTokenDuration *time.Duration
}

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