Class Middleware
Methods Summary
-
static
sourceFile ( Aws\Api\Service $api, string $bodyParameter = 'Body', string $sourceParameter = 'SourceFile' )
Middleware used to allow a command parameter (e.g., "SourceFile") to be used to specify the source of data for an upload operation.
-
static
validation ( Aws\Api\Service $api, Aws\Api\Validator $validator = null )
Adds a middleware that uses client-side validation.
-
static
requestBuilder ( callable $serializer, EndpointProviderV2 $endpointProvider = null, array $providerArgs = null )
Builds an HTTP request for a command.
-
static
signer ( callable $credProvider, callable $signatureFunction, $tokenProvider = null )
Creates a middleware that signs requests for a command.
-
static
tap ( callable $fn )
Creates a middleware that invokes a callback at a given step.
-
static
retry ( callable $decider = null, callable $delay = null, bool $stats = false )
Middleware wrapper function that retries requests based on the boolean result of invoking the provided "decider" function.
-
static
invocationId ( )
Middleware wrapper function that adds an invocation id header to requests, which is only applied after the build step.
-
static
contentType ( array $operations )
Middleware wrapper function that adds a Content-Type header to requests. This is only done when the Content-Type has not already been set, and the request body's URI is available. It then checks the file extension of the URI to determine the mime-type.
-
static
recursionDetection ( )
Middleware wrapper function that adds a trace id header to requests from clients instantiated in supported Lambda runtime environments.
-
static
history ( Aws\History $history )
Tracks command and request history using a history container.
-
static
mapRequest ( callable $f )
Creates a middleware that applies a map function to requests as they pass through the middleware.
-
static
mapCommand ( callable $f )
Creates a middleware that applies a map function to commands as they pass through the middleware.
-
static
mapResult ( callable $f )
Creates a middleware that applies a map function to results.
- static timer ( )
Methods Details
static
callable
sourceFile (
Aws\Api\Service
$api,
string
$bodyParameter = 'Body',
string
$sourceParameter = 'SourceFile'
)
Middleware used to allow a command parameter (e.g., "SourceFile") to be used to specify the source of data for an upload operation.
Parameters
Aws\Api\Service |
$api | |
string | $bodyParameter = 'Body' | |
string | $sourceParameter = 'SourceFile' |
Returns
callable |
static
callable
validation (
Aws\Api\Service
$api,
Aws\Api\Validator
$validator = null
)
Adds a middleware that uses client-side validation.
Parameters
Aws\Api\Service |
$api | API being accessed. |
Aws\Api\Validator |
$validator = null |
Returns
callable |
static
callable
requestBuilder (
callable
$serializer,
Aws\EndpointV2\EndpointProviderV2
$endpointProvider = null,
array
$providerArgs = null
)
Builds an HTTP request for a command.
Parameters
callable | $serializer | Function used to serialize a request for a command. |
Aws\EndpointV2\EndpointProviderV2 |
$endpointProvider = null | null $endpointProvider |
array | $providerArgs = null |
Returns
callable |
static callable signer ( callable $credProvider, callable $signatureFunction, $tokenProvider = null )
Creates a middleware that signs requests for a command.
Parameters
callable | $credProvider | Credentials provider function that returns a promise that is resolved with a CredentialsInterface object. |
callable | $signatureFunction | Function that accepts a Command object and returns a SignatureInterface. |
$tokenProvider = null |
Returns
callable |
static callable tap ( callable $fn )
Creates a middleware that invokes a callback at a given step.
The tap callback accepts a CommandInterface and RequestInterface as arguments but is not expected to return a new value or proxy to downstream middleware. It's simply a way to "tap" into the handler chain to debug or get an intermediate value.
Parameters
callable | $fn | Tap function |
Returns
callable |
static callable retry ( callable $decider = null, callable $delay = null, boolean $stats = false )
Middleware wrapper function that retries requests based on the boolean result of invoking the provided "decider" function.
If no delay function is provided, a simple implementation of exponential backoff will be utilized.
Parameters
callable | $decider = null | Function that accepts the number of retries, a request, [result], and [exception] and returns true if the command is to be retried. |
callable | $delay = null | Function that accepts the number of retries and returns the number of milliseconds to delay. |
boolean | $stats = false | Whether to collect statistics on retries and the associated delay. |
Returns
callable |
static callable invocationId ( )
Middleware wrapper function that adds an invocation id header to requests, which is only applied after the build step.
This is a uniquely generated UUID to identify initial and subsequent retries as part of a complete request lifecycle.
Returns
callable |
static callable contentType ( array $operations )
Middleware wrapper function that adds a Content-Type header to requests. This is only done when the Content-Type has not already been set, and the request body's URI is available. It then checks the file extension of the URI to determine the mime-type.
Parameters
array | $operations | Operations that Content-Type should be added to. |
Returns
callable |
static callable recursionDetection ( )
Middleware wrapper function that adds a trace id header to requests from clients instantiated in supported Lambda runtime environments.
The purpose for this header is to track and stop Lambda functions from being recursively invoked due to misconfigured resources.
Returns
callable |
static
callable
history (
Aws\History
$history
)
Tracks command and request history using a history container.
This is useful for testing.
Parameters
Aws\History |
$history | History container to store entries. |
Returns
callable |
static callable mapRequest ( callable $f )
Creates a middleware that applies a map function to requests as they pass through the middleware.
Parameters
callable | $f | Map function that accepts a RequestInterface and returns a RequestInterface. |
Returns
callable |
static callable mapCommand ( callable $f )
Creates a middleware that applies a map function to commands as they pass through the middleware.
Parameters
callable | $f | Map function that accepts a command and returns a command. |
Returns
callable |
static callable mapResult ( callable $f )
Creates a middleware that applies a map function to results.
Parameters
callable | $f | Map function that accepts an Aws\ResultInterface and returns an Aws\ResultInterface. |
Returns
callable |