Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var (
ErrNilInjector = errors.New("nil response injector")
)
Functions ¶
func GetHeadersFromRequestContext ¶
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
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