Class HandlerStack
Creates a composed Guzzle handler function by stacking middlewares on top of
an HTTP handler function.
Methods summary
public static
GuzzleHttp\HandlerStack
|
#
create( callable $handler = null )
Creates a default handler stack that can be used by clients.
Creates a default handler stack that can be used by clients.
The returned handler will wrap the provided handler or use the most
appropriate default handler for you system. The returned HandlerStack has
support for cookies, redirects, HTTP error exceptions, and preparing a body
before sending.
The returned handler stack can be passed to a client in the "handler"
option.
Parameters
- $handler
HTTP handler function to use with the stack. If no
handler is provided, the best handler for your
system will be utilized.
Returns
|
public
|
#
__construct( callable $handler = null )
Parameters
- $handler
- Underlying HTTP handler.
|
public
|
|
public
string
|
#
__toString( )
Dumps a string representation of the stack.
Dumps a string representation of the stack.
Returns
string
|
public
|
#
setHandler( callable $handler )
Set the HTTP handler that actually returns a promise.
Set the HTTP handler that actually returns a promise.
Parameters
- $handler
Accepts a request and array of options and
returns a Promise.
|
public
boolean
|
#
hasHandler( )
Returns true if the builder has a handler.
Returns true if the builder has a handler.
Returns
boolean
|
public
|
#
unshift( callable $middleware, string $name = null )
Unshift a middleware to the bottom of the stack.
Unshift a middleware to the bottom of the stack.
Parameters
- $middleware
- Middleware function
- $name
- Name to register for this middleware.
|
public
|
#
push( callable $middleware, string $name = '' )
Push a middleware to the top of the stack.
Push a middleware to the top of the stack.
Parameters
- $middleware
- Middleware function
- $name
- Name to register for this middleware.
|
public
|
#
before( string $findName, callable $middleware, string $withName = '' )
Add a middleware before another middleware by name.
Add a middleware before another middleware by name.
Parameters
- $findName
- Middleware to find
- $middleware
- Middleware function
- $withName
- Name to register for this middleware.
|
public
|
#
after( string $findName, callable $middleware, string $withName = '' )
Add a middleware after another middleware by name.
Add a middleware after another middleware by name.
Parameters
- $findName
- Middleware to find
- $middleware
- Middleware function
- $withName
- Name to register for this middleware.
|
public
|
#
remove( callable|string $remove )
Remove a middleware by instance or name from the stack.
Remove a middleware by instance or name from the stack.
Parameters
- $remove
- Middleware to remove by instance or name.
|
public
callable
|
#
resolve( )
Compose the middleware and handler into a single callable function.
Compose the middleware and handler into a single callable function.
Returns
callable
|