liveBook · Manning

Middleware

Middleware is an intermediate software component or layer that processes or mediates requests, messages, or operations between other components, often adding behavior or controlling their flow.

How 10 Manning books explain it

ASP.NET Core in Action, 3e

Middleware is a request-processing component that can inspect, modify, or handle HTTP requests and responses within an ASP.NET Core pipeline.

How it is used
Handles cross-cutting HTTP request and response work, including logging, static files, and error handling.
How deep it goes
Explains two-way flow, short-circuiting, ordering, and composition with existing components; defers building custom middleware.
Examples
Uses a welcome page, development-only HTTP logging, and a minimal API returning JSON to show pipeline behavior.
What you can do after
Operate/configure it through WebApplication Use* calls, ordering components and choosing middleware rather than filters when endpoint-specific details are unnecessary.

Read how ASP.NET Core in Action, 3e explains middleware →

Pro ASP.NET Core 7, Tenth Edition

Middleware is a component in an ASP.NET Core request pipeline that processes HTTP requests and responses.

How it is used
Processes HTTP requests and responses in an ordered ASP.NET Core pipeline, either producing responses or supplying features to later components.
How deep it goes
Builds lambda and class components, including forwarding, return-path changes, short-circuiting, thread safety, and options; delegates raw HTTP parsing to ASP.NET Core.
Examples
Uses Program.cs components that check a GET query parameter, append a status code, and expose session data through HttpContext.
What you can do after
Build it from scratch: register lambda or class middleware and control whether it forwards a request or changes its response.

Read how Pro ASP.NET Core 7, Tenth Edition explains middleware →

Go by Example

Middleware is a software pattern in which a component wraps a handler or processing component to add behavior before, after, or around the wrapped component's execution.

How it is used
Adds cross-cutting HTTP behavior around handlers without modifying route-handler code.
How deep it goes
Builds logger, duration, status-code, and trace-ID wrappers, including chaining, ResponseWriter interception, and Context caveats.
Examples
Uses a REST ServeMux, request logs, duration and status metrics, curl requests, and trace-ID propagation.
What you can do after
Build it from scratch: chain HTTP wrappers that log requests, collect response metrics, and propagate trace IDs.

Read how Go by Example explains middleware →

Building Web APIs with ASP.NET Core

Middleware is an HTTP-level component that processes a request and either passes it to the next pipeline component or produces a response.

How it is used
Handles HTTP requests through a configurable pipeline, including caching defaults and JWT authentication.
How deep it goes
Defines terminal behavior and walks through registration, a custom Use callback, and response-header checks without exploring pipeline internals.
Examples
Uses a Program.cs starter pipeline, a no-cache callback, response-header checks, and JWT authentication setup.
What you can do after
Build it from scratch by adding a Use callback in Program.cs and verifying its cache-control fallback.

Read how Building Web APIs with ASP.NET Core explains middleware →

Django in Action

Middleware is software that sits in a request-processing pipeline and can modify processing or prevent a downstream handler from being called.

How it is used
Coordinates authentication, sessions, and other cross-request behavior around Django views.
How deep it goes
Defines pipeline placement and configuration, while deferring factory-function or class middleware implementation to Django documentation.
Examples
Uses session login control, a protected band page, and Debug Toolbar installation on a musician listing.
What you can do after
Operate/configure it by placing DebugToolbarMiddleware correctly and recognizing middleware as a home for repeated view logic.

Read how Django in Action explains middleware →

Learn Docker in a Month of Lunches, Second Edition

A Traefik middleware is a request-processing component that modifies or validates traffic before forwarding it to a service.

How it is used
Uses request transformations and validation between HTTP routers and upstream services.
How deep it goes
Defines path, header, and authentication uses, then demonstrates path-prefix rewriting without detailing middleware labels.
Examples
Uses an image gallery API mounted under an /api path and verified with curl.
What you can do after
Configure path rewriting for a routed container application and verify the resulting website and API requests.

Read how Learn Docker in a Month of Lunches, Second Edition explains middleware →

Secure APIs

Middleware is software that intercepts and processes requests or responses between a client and an application endpoint.

How it is used
Protects API requests by combining authentication, authorization, and business-flow checks before endpoint processing.
How deep it goes
Demonstrates implementation through a ticketing example but acknowledges that the mitigation only scratches the surface of abuse prevention.
Examples
Uses ticket checkout, allowed user agents, authenticated user claims, and 24-hour transaction records as concrete artifacts.
What you can do after
Build custom request middleware that rejects unauthorized clients and prevents repeated purchases according to application rules.

Read how Secure APIs explains middleware →

Build AI-Enhanced Web Apps

Middleware is software that intercepts and processes requests between a client and an application handler.

How it is used
Deploys middleware as an early security layer for authentication, CORS, rate limiting, and security headers.
How deep it goes
Explains sequential composition, short-circuiting, stopping, error handling, route matching, and edge placement without detailing provider internals.
Examples
Uses composable Next.js middleware, Clerk-protected chat routes, CORS checks, Upstash Redis rate limits, and authentication redirects.
What you can do after
Operate/configure Next.js request pipelines that authenticate users, restrict origins, limit traffic, set headers, and handle middleware failures.

Read how Build AI-Enhanced Web Apps explains middleware →

Learn Haskell by Example

Middleware is a function or component that wraps a web application to inspect or transform requests and responses before delegating to the wrapped application.

How it is used
Adds behavior or routes around a WAI Application without changing the underlying Servant API type.
How deep it goes
Defines the Application -> Application shape and works through request matching, response construction, delegation, and composition.
Examples
Uses a todo-list root page that sorts database entries, renders HTML, and leaves other requests to the API server.
What you can do after
Build it from scratch by wrapping an Application, matching requests, creating responses, and delegating unmatched traffic.

Read how Learn Haskell by Example explains middleware →

Build Financial Software with Generative AI (From Scratch)

Middleware is software that intercepts and processes requests or responses between an application and its surrounding interfaces.

How it is used
Centralizes API request logging and auditing so endpoint code stays focused and avoids repeated boilerplate.
How deep it goes
Explains registration, request-response flow, audit fields, persistence, and decorator-based customization, without covering deployment configuration.
Examples
Uses API request records, ACH-file retrieval messages, client metadata, response codes, URLs, and an AuditLog utility.
What you can do after
Operate/configure FastAPI middleware to log API calls and attach endpoint-specific audit messages.

Read how Build Financial Software with Generative AI (From Scratch) explains middleware →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.