6.0.0-git
2021-07-26

Diff for Doc/Dev/HordeHttpServer between and 1

+ Horde_Http_Server Middleware and Request Handler

Horde_Http_Server is the Horde 6 successor to ((Doc/Dev/HordeController|Horde_Controller)) and the Horde Rampage MVC framework of Horde 5.
It uses the PSR-compatible ServerRequest and Response implementations from ((Doc/Dev/HordeHttp|Horde_Http)).

++ Upgrading

PreFilters and PostFilters have been redesigned to be PSR-15 Middleware.
PreFilters are middleware which either returns their own response or modifies a request before returning it to the handler.
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.
They are now replaced by a special Request Handler, the !RampageRequestHandler. It holds a stack of Middlewares and optionally a single payload request handler.
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.

++ 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.