\documentclass{article}
\usepackage{ulem}
\pagestyle{headings}
\begin{document}
\part{ Horde\_Http\_Server Middleware and Request Handler}
Horde\_Http\_Server is the Horde 6 successor to Horde\_Controller\footnote{http://example.com/index.php?page=Doc/Dev/HordeController} and the Horde Rampage MVC framework of Horde 5.\newline
It uses the PSR-7 compatible ServerRequest and Response implementations from Horde\_Http\footnote{http://example.com/index.php?page=Doc/Dev/HordeHttp}.

\section{ Upgrading}
PreFilters and PostFilters have been redesigned to be PSR-15 Middleware.\newline
PreFilters are middleware which either returns their own response or modifies a request before returning it to the handler.\newline
PostFilters are middleware which modifies a Response created by a deeper layer of middleware or by the handler.

Controllers can be implemented either as Payload Request Handlers or as Middleware intended to be called last in the queue.

The RequestConfiguration and SettingsExporter from the Controller Framework wired together PreFilters, PostFilters and Controller.\newline
They are now replaced by a special Request Handler, the RampageRequestHandler. It holds a stack of Middlewares and optionally a single payload request handler.\newline
The middleware stack can be extended by processing layers of middleware. This allows us to delay initialisation of portions of the Horde framework which may be needed only later.

\section{ Understanding Middleware and Handler}
Think of middleware as a stack of layers and the Handler as its bottom. A request enters from the top layer and progresses down. Each layer may modify the request. Each layer may let the request pass down to the next layer or create a response which will pass backwards up through each layer. Each layer may in turn modify the response. The handler finally MUST create a response out of the request as it is the bottom layer.

The upper layers will have tasks which either need to happen first or last. Think of routing the request, which would either add more middleware to the bottom of the stack or set a payload handler. Think of an error handler offering a user friendly message. Think of authentication and authorization - they may immediately throw back an answer and the request may never reach the bottom of the stack.

Bottom middlewares or payload handlers would represent the actual core of your application - processing the actual data from the request and returning content, either a UI or maybe an API response like a JSON document.

\end{document}
