middleware
Code that sits between an incoming request and the handler that answers it, doing a shared job such as logging, authentication or rate limiting.
In more detail
Each request passes through the middleware chain before reaching the handler. A rate limiter is a common piece of HTTP middleware.
Related terms
- rate limiting — Capping how many requests a client may make in a period of time, and rejecting or delaying the rest.
- HTTP — The protocol web browsers and web servers use to send requests and responses.
- cross-cutting concern — A need that applies across many services or endpoints, such as authentication, rate limiting, logging or TLS, rather than to one feature.
- API gateway — A server that sits in front of one or more services and handles shared concerns such as routing, authentication, rate limits and TLS for every request.
- middleware pipeline — The ordered chain of middleware every HTTP request passes through on the way in, and in reverse on the way out.
- next delegate — The delegate a middleware calls to pass the request to the rest of the pipeline, and whose completion signals the response is on its way back.
- short-circuiting — A middleware ending a request by writing the response itself instead of calling the next component.
- HttpContext — The ASP.NET Core object holding everything about the current HTTP request and response, including the user, headers, path and request services.
- authentication — Establishing who a request represents, for example by checking a password, a session cookie or a signed token.
- procedure — One callable server function in a tRPC router, declared as a query (read) or a mutation (write), with a validated input.
- request context — The information attached to a single request, such as who made it, when and from where, that code or access policies check while handling it.
- middleware.ts — A single file at the project root that runs code before matching requests are routed, to redirect, rewrite, set headers or check sessions.
- higher-order function — A function that takes a function as an argument or returns one, such as map, filter or a wrapper that adds retries.
- routing — Choosing which piece of code handles a request, based on its method and path, such as GET /users/42.
- web framework — A library that provides the structure for building web applications, such as routing, middleware and request parsing, so you do not write them yourself.
- wrapper function — A function that calls another function, adding behaviour before or after it, such as timing, retries or logging.
- Express — The most widely used web framework for Node.js, providing routing and middleware on top of node:http.
Taught in
- Choosing The Right Sequence — Algorithms & Data Structures for Working Engineers
- API Gateways And Proxies — Modern API Architecture: REST, GraphQL & gRPC
- What is .NET? Runtime vs SDK, and LTS vs STS — Modern .NET Core, C# & Enterprise Microservices
- The ASP.NET Core Middleware Pipeline — Modern .NET Core, C# & Enterprise Microservices
- Building Routes with Minimal APIs — Modern .NET Core, C# & Enterprise Microservices
- Comparing Controllers and Minimal APIs — Modern .NET Core, C# & Enterprise Microservices
- Global Exception Handling and Problem Details — Modern .NET Core, C# & Enterprise Microservices
- Built-in Rate Limiting Middleware — Modern .NET Core, C# & Enterprise Microservices
- Integration Testing with WebApplicationFactory — Modern .NET Core, C# & Enterprise Microservices
- End-to-End Type Safety: Shared Schemas & DTOs — Production Full-Stack Engineering
- API Contract Architecture: OpenAPI 3.1 & Schema Truth — Production Full-Stack Engineering
- Type-Safe RPC Architectures: tRPC & Procedures — Production Full-Stack Engineering
- Resilient Error Handling: Problem Details & Envelopes — Production Full-Stack Engineering
- Multi-Tenant Identity: Tenant Isolation & Middleware — Production Full-Stack Engineering
- Distributed Tracing: OpenTelemetry & Traceparent — Production Full-Stack Engineering
- Structured Logging & Correlation IDs: Context Stitching — Production Full-Stack Engineering
- Traffic Management: Sliding Window Rate Limiting — Production Full-Stack Engineering
- Server Action Security: Zod Validation & Auth Gates — Next.js 15 & Modern App Router Architecture
- Revalidation Strategies: revalidatePath & Cache Life — Next.js 15 & Modern App Router Architecture
- Streaming Endpoints: Server-Sent Events & NDJSON Feeds — Next.js 15 & Modern App Router Architecture
- Edge Middleware: Auth Verification & Route Matchers — Next.js 15 & Modern App Router Architecture
- Session Management: Secure Cookies & Token Validation — Next.js 15 & Modern App Router Architecture
- Instrumentation: OpenTelemetry & Performance Spans — Next.js 15 & Modern App Router Architecture
- Routing & Middleware: Path Parsing & Async Context — Node.js Internals & Backend Services
- Diagnostic Profiling: CPU Profiler & Heap Snapshots — Node.js Internals & Backend Services
- Type Aliases Versus Interfaces: Declaration Merging — Production TypeScript
- Tuples: Fixed Length, Labeled Elements And Variadic Tuples — Production TypeScript
- Function Utilities: ReturnType, Parameters And Constructor — Production TypeScript
- Mapped Types, Key Remapping With as And Template Literals — Production TypeScript
- Declaration Files, Ambient Namespaces And Module Augmentation — Production TypeScript
- Modern Decorators: Stage 3 Standards And Class Metadata — Production TypeScript