jargon

Comparison

InterceptorvsMiddleware

Interceptor

logging appeared around every method in the service and there is no line of your code that calls it.

A hook that a framework runs around a call, letting cross-cutting behaviour be attached without editing the target — the mechanism behind aspect-oriented programming, servlet filters, gRPC interceptors and most annotation-driven transactions. It is a decorator that you did not write and cannot see at the call site, which is both the appeal and the cost. Debugging is where the bill arrives: the stack trace names classes nobody wrote.

Full entry →

Middleware

each function takes the next one and returns a new one, so authentication wrapped logging wrapped the actual handler.

A composable wrapper around a handler that can act before it, after it, or instead of it, stacked into a pipeline. It is the decorator pattern written as functions and assembled as a chain of responsibility, which is why it is the shape every web framework converged on independently. Its recurring difficulty is order: authentication before rate limiting and rate limiting before authentication are different products.

Full entry →

Related comparisons