Every time a user visits a page on your site, they create a request, using HTTP, and get a response, also over HTTP. The HttpRequest and HttpResponse form the basics of any request from the client - we read the input (HttpRequest) and write the output (HttpResponse).
Each request goes through the following lifecycle:
-
We set up the
HttpContext
object with ourHttpRequest
andHttpResponse
. -
This
HttpContext
is then passed through the various modules:- Each UFRequestMiddleware, in order.
- Each UFRequestHandler, in order.
- Each UFResponseMiddleware, in order.
- Each UFLogHandler, in order.
Each module has can change some details of the
HttpContext
, or mark parts of the request as complete. For example, a request middleware could load a result from the cache, write it to theHttpResponse
, and so mark the request as complete, so no further processing is required.If an error is encountered, then the
HttpContext
is then passed through:- Each UFErrorHandler, in order. The given error value is also passed to the error handler.
- Each UFLogHandler, in order.
-
Once each module has run it's course, we flush the
HttpResponse
to the client, and wrap up the request.
- On PHP, for every request, a UfrontApplication is created, a HttpContext is created, and the request is executed.
- Neko without
neko.Web.cacheModule
behaves the same as PHP. - Neko with
neko.Web.cacheModule
will load the UfrontApplication on the first request, and keep one copy alive for each thread. For each request, one of the existing threads will be used, theHttpContext
will be created, and the request will be executed. - On Node JS, a
UfrontApplication
is created, and aHttpServer
launched. Each HTTP request from the server is then converted to aHttpContext
and executed accordingly.