Overview

Namespaces

  • Baguette
    • Mastodon
      • Config
      • Entity
      • Grant
      • Service
  • GuzzleHttp
    • Cookie
    • Exception
    • Handler
    • Promise
  • Psr
    • Http
      • Message
  • Teto
    • Object

Classes

  • Client
  • HandlerStack
  • MessageFormatter
  • Middleware
  • Pool
  • PrepareBodyMiddleware
  • RedirectMiddleware
  • RequestOptions
  • RetryMiddleware
  • TransferStats
  • UriTemplate

Interfaces

  • ClientInterface

Functions

  • choose_handler
  • debug_resource
  • default_ca_bundle
  • default_user_agent
  • describe_type
  • headers_from_lines
  • is_host_in_noproxy
  • json_decode
  • json_encode
  • normalize_header_keys
  • uri_template
  • Overview
  • Namespace
  • Class

Class Middleware

Functions used to create and wrap handlers with handler middleware.

Final
Namespace: GuzzleHttp
Located at Middleware.php
Methods summary
public static callable
# cookies( )

Middleware that adds cookies to requests.

Middleware that adds cookies to requests.

The options array must be set to a CookieJarInterface in order to use cookies. This is typically handled for you by a client.

Returns

callable
Returns a function that accepts the next handler.
public static callable
# httpErrors( )

Middleware that throws exceptions for 4xx or 5xx responses when the "http_error" request option is set to true.

Middleware that throws exceptions for 4xx or 5xx responses when the "http_error" request option is set to true.

Returns

callable
Returns a function that accepts the next handler.
public static callable
# history( array & $container )

Middleware that pushes history data to an ArrayAccess container.

Middleware that pushes history data to an ArrayAccess container.

Parameters

$container
Container to hold the history (by reference).

Returns

callable
Returns a function that accepts the next handler.

Throws

InvalidArgumentException
if container is not an array or ArrayAccess.
public static callable
# tap( callable $before = null, callable $after = null )

Middleware that invokes a callback before and after sending a request.

Middleware that invokes a callback before and after sending a request.

The provided listener cannot modify or alter the response. It simply "taps" into the chain to be notified before returning the promise. The before listener accepts a request and options array, and the after listener accepts a request, options array, and response promise.

Parameters

$before
Function to invoke before forwarding the request.
$after
Function invoked after forwarding.

Returns

callable
Returns a function that accepts the next handler.
public static callable
# redirect( )

Middleware that handles request redirects.

Middleware that handles request redirects.

Returns

callable
Returns a function that accepts the next handler.
public static callable
# retry( callable $decider, callable $delay = null )

Middleware that retries requests based on the boolean result of invoking the provided "decider" function.

Middleware 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

$decider

Function that accepts the number of retries, a request, [response], and [exception] and returns true if the request is to be retried.

$delay

Function that accepts the number of retries and returns the number of milliseconds to delay.

Returns

callable
Returns a function that accepts the next handler.
public static callable
# log( Psr\Log\LoggerInterface $logger, GuzzleHttp\MessageFormatter $formatter, string $logLevel = GuzzleHttp\LogLevel::INFO )

Middleware that logs requests, responses, and errors using a message formatter.

Middleware that logs requests, responses, and errors using a message formatter.

Parameters

$logger
Logs messages.
$formatter
Formatter used to create message strings.
$logLevel
Level at which to log requests.

Returns

callable
Returns a function that accepts the next handler.
public static callable
# prepareBody( )

This middleware adds a default content-type if possible, a default content-length or transfer-encoding header, and the expect header.

This middleware adds a default content-type if possible, a default content-length or transfer-encoding header, and the expect header.

Returns

callable
public static callable
# mapRequest( callable $fn )

Middleware that applies a map function to the request before passing to the next handler.

Middleware that applies a map function to the request before passing to the next handler.

Parameters

$fn

Function that accepts a RequestInterface and returns a RequestInterface.

Returns

callable
public static callable
# mapResponse( callable $fn )

Middleware that applies a map function to the resolved promise's response.

Middleware that applies a map function to the resolved promise's response.

Parameters

$fn

Function that accepts a ResponseInterface and returns a ResponseInterface.

Returns

callable
ξ ^ω^)ξ Baguette PHP Mastodon API Client / SDK API documentation generated by ApiGen