hooks

package
v0.2.20 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

README

Configuration through environment variables

This SDK can be configured via the environment variables.

Konnect domain

Konnect domain can be customized via KONG_CUSTOM_DOMAIN environment variable. This is useful when testing against a development environment or a custom domain. This is optional and the default value is konghq.com.

Request and response logging

Request and response logging can be enabled via:

  • KONNECT_SDK_HTTP_DUMP_REQUEST: Set to true to log request bodies.
  • KONNECT_SDK_HTTP_DUMP_RESPONSE: Set to true to log response bodies.
  • KONNECT_SDK_HTTP_DUMP_RESPONSE_ERROR: Set to true to log response bodies only when the response status code is an error.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIURLRequestHook

type APIURLRequestHook struct {
	CustomDomain string
}

func (*APIURLRequestHook) BeforeRequest

func (i *APIURLRequestHook) BeforeRequest(hookCtx BeforeRequestContext, req *http.Request) (*http.Request, error)

Replace `.konghq.com` with the custom domain set in the `KONG_CUSTOM_DOMAIN` environment variable.

type AfterErrorContext

type AfterErrorContext struct {
	HookContext
}

type AfterSuccessContext

type AfterSuccessContext struct {
	HookContext
}

type BeforeRequestContext

type BeforeRequestContext struct {
	HookContext
}

type FailEarly

type FailEarly struct {
	Cause error
}

func (*FailEarly) Error

func (f *FailEarly) Error() string

type GlobalAPIURLRequestHook

type GlobalAPIURLRequestHook struct{}

func (*GlobalAPIURLRequestHook) BeforeRequest

func (i *GlobalAPIURLRequestHook) BeforeRequest(hookCtx BeforeRequestContext, req *http.Request) (*http.Request, error)

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 HTTPDumpRequestHook

type HTTPDumpRequestHook struct{}

HTTPDumpRequestHook is a hook that dumps the request to stdout.

func (*HTTPDumpRequestHook) BeforeRequest

func (i *HTTPDumpRequestHook) BeforeRequest(hookCtx BeforeRequestContext, req *http.Request) (*http.Request, error)

BeforeRequest dumps the request to stdout if enabled.

type HTTPDumpResponseErrorHook

type HTTPDumpResponseErrorHook struct{}

HTTPDumpResponseErrorHook is a hook that dumps the error response to stdout.

func (*HTTPDumpResponseErrorHook) AfterError

func (i *HTTPDumpResponseErrorHook) AfterError(hookCtx AfterErrorContext, res *http.Response, err error) (*http.Response, error)

AfterError dumps the error response to stdout if enabled.

type HTTPDumpResponseHook

type HTTPDumpResponseHook struct{}

HTTPDumpResponseHook is a hook that dumps the response to stdout.

func (*HTTPDumpResponseHook) AfterSuccess

func (i *HTTPDumpResponseHook) AfterSuccess(hookCtx AfterSuccessContext, res *http.Response) (*http.Response, error)

AfterSuccess dumps the response to stdout if enabled.

type HookContext

type HookContext struct {
	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 UserAgentPreRequestHook

type UserAgentPreRequestHook struct{}

func (*UserAgentPreRequestHook) BeforeRequest

func (i *UserAgentPreRequestHook) BeforeRequest(hookCtx BeforeRequestContext, req *http.Request) (*http.Request, error)

Jump to

Keyboard shortcuts

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