Interceptor typedef

Interceptor = AnyFn<I, O> Function<I extends Object, O extends Object>(AnyFn<I, O> next)

An interceptor can add logic to clients or servers, similar to the decorators or middleware you may have seen in other libraries. Interceptors may mutate the request and response, catch errors and retry/recover, emit logs, or do nearly everything else.

You can think of interceptors like a layered onion. A request initiated by a client goes through the outermost layer first. In the center, the actual HTTP request is run by the transport. The response then comes back through all layers and is returned to the client.

To implement that layering, Interceptors are functions that wrap a call invocation. In an array of interceptors, the interceptor at the end of the array is applied first.

Implementation

typedef Interceptor = AnyFn<I, O> Function<I extends Object, O extends Object>(
  AnyFn<I, O> next,
);