Documentation ¶
Overview ¶
Package awsmiddleware defines an extension interface providing request and response handlers that can be configured on AWS SDK clients.
Index ¶
- func GetOperationName(ctx context.Context) string
- func GetRequestID(ctx context.Context) string
- func TryConfigure(logger *zap.Logger, host component.Host, middlewareID component.ID, ...)
- type Configurer
- type Extension
- type HandlerPosition
- type Middleware
- type MockExtensionsHost
- type MockHandler
- type MockMiddlewareExtension
- type RequestHandler
- type ResponseHandler
- type SDKVersion
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetOperationName ¶
GetOperationName retrieves the service operation metadata from the context.
func GetRequestID ¶
GetRequestID retrieves the generated request ID from the context.
func TryConfigure ¶
func TryConfigure(logger *zap.Logger, host component.Host, middlewareID component.ID, sdkVersion SDKVersion)
TryConfigure is a helper function that will try to get the extension and configure the provided AWS SDK with it.
Types ¶
type Configurer ¶
type Configurer struct {
// contains filtered or unexported fields
}
Configurer provides functions for applying request/response handlers to the AWS SDKs.
func GetConfigurer ¶
func GetConfigurer(extensions map[component.ID]component.Component, middlewareID component.ID) (*Configurer, error)
GetConfigurer retrieves the extension implementing Middleware based on the middlewareID and wraps it in a Configurer.
func NewConfigurer ¶
func NewConfigurer(requestHandlers []RequestHandler, responseHandlers []ResponseHandler) *Configurer
NewConfigurer sets the request/response handlers.
func (Configurer) Configure ¶
func (c Configurer) Configure(sdkVersion SDKVersion) error
Configure configures the handlers on the provided AWS SDK.
type Extension ¶
type Extension interface { extension.Extension Middleware }
Extension is an extension that implements Middleware.
type HandlerPosition ¶
type HandlerPosition int
HandlerPosition is the relative position of a handler used during insertion.
const ( After HandlerPosition = iota Before )
func (HandlerPosition) MarshalText ¶
func (h HandlerPosition) MarshalText() (text []byte, err error)
MarshalText converts the position into a byte slice. Returns an error if unsupported.
func (HandlerPosition) String ¶
func (h HandlerPosition) String() string
String returns the string representation of the position. Returns an empty string if position is unsupported.
func (*HandlerPosition) UnmarshalText ¶
func (h *HandlerPosition) UnmarshalText(text []byte) error
UnmarshalText converts the string into a position. Returns an error if unsupported.
type Middleware ¶
type Middleware interface {
Handlers() ([]RequestHandler, []ResponseHandler)
}
Middleware defines the request and response handlers to be configured on AWS Clients.
type MockExtensionsHost ¶
MockExtensionsHost only mocks the GetExtensions function. All other functions are ignored and will panic if called.
func (*MockExtensionsHost) GetExtensions ¶
func (m *MockExtensionsHost) GetExtensions() map[component.ID]component.Component
type MockHandler ¶
MockHandler mocks the functions for both RequestHandler and ResponseHandler.
func (*MockHandler) HandleRequest ¶
func (m *MockHandler) HandleRequest(ctx context.Context, r *http.Request)
func (*MockHandler) HandleResponse ¶
func (m *MockHandler) HandleResponse(ctx context.Context, r *http.Response)
func (*MockHandler) ID ¶
func (m *MockHandler) ID() string
func (*MockHandler) Position ¶
func (m *MockHandler) Position() HandlerPosition
type MockMiddlewareExtension ¶
MockMiddlewareExtension mocks the Extension interface.
func (*MockMiddlewareExtension) Handlers ¶
func (m *MockMiddlewareExtension) Handlers() ([]RequestHandler, []ResponseHandler)
type RequestHandler ¶
type RequestHandler interface { HandleRequest(ctx context.Context, r *http.Request) // contains filtered or unexported methods }
RequestHandler allows for custom processing of requests.
type ResponseHandler ¶
type ResponseHandler interface { HandleResponse(ctx context.Context, r *http.Response) // contains filtered or unexported methods }
ResponseHandler allows for custom processing of responses.
type SDKVersion ¶
type SDKVersion interface {
// contains filtered or unexported methods
}
func SDKv1 ¶
func SDKv1(handlers *request.Handlers) SDKVersion
SDKv1 takes in AWS SDKv1 client request handlers.