Skip to content

Middleware vs filter vs interceptor vs decorator

Middleware wraps the request flow, filters do similar work in specific frameworks, interceptors target method calls, decorators target individual functions.

Aspect

Middleware

Filter

Interceptor

Decorator

Scope

Full request/response

Servlet filters

Method calls

One function

Typical framework

Express, Laravel, ASP.NET Core

Spring, Java EE

NestJS, Angular

Python, TypeScript

Can short-circuit

Yes

Yes

Yes

No

Order matters

Yes

Yes

Yes

No