AXIAM PHP SDK

RefreshMiddleware
in package

FinalYes

`HandlerStack` middleware: on a `401` response, triggers the session's single-flight refresh (CONTRACT.md §9, D-06, SC#2) and retries the ORIGINAL request exactly once via the inner `$handler` — never a loop. All concurrent 401-triggering requests on one {@see Session} share the SAME refresh `PromiseInterface` ({@see Session::refreshIfNeeded()}), so N concurrent expired-token requests still result in exactly one `/api/v1/auth/refresh` call.

Registered OUTSIDE (further from the base handler than) AuthMiddleware on the HandlerStack, so the retry — invoked via the $handler captured here, which is everything BELOW this middleware, i.e. AuthMiddleware + the base handler — never re-enters this middleware's own 401 check a second time (retry-exactly-once by construction, not by an explicit retry counter).

Table of Contents

Methods

__construct()  : mixed
__invoke()  : callable
Wraps the next Guzzle handler so a 401 triggers a single-flight token refresh and one replay of the original request.

Methods

__invoke()

Wraps the next Guzzle handler so a 401 triggers a single-flight token refresh and one replay of the original request.

public __invoke(callable $handler) : callable

The replay is issued through the NEXT handler rather than the top of the stack, so it cannot re-enter this middleware's 401 check — retry-exactly-once by construction, with no explicit retry counter and no infinite refresh loop.

Parameters
$handler : callable

Next handler in the Guzzle stack.

Return values
callable

Decorated handler.

On this page

Search results