-
Notifications
You must be signed in to change notification settings - Fork 1
Middlewares
A middleware is function called before invoking a actual action function. It can modify the HTTP request before passed to the next procedure, and modify the response returned from the next procedure, too. It can also send a response back to client earlier.
File config/middlewares.lisp
contains the middlewares' functions to be invoked in order. A middleware's function must be exported from its package.
Each middleware function's parameter list looks like the following form:
(request next &key config)
-
request
is an instance of HTTP request; -
next
is the function for processing request at the next step; -
config
is the configuration of application
For every request, collects information from both request and response, and write to log files under directory log/
. The structure of one line log message is similar the the access log of nginx.
For every request, if the value of the header Accept-Encoding
includes a sub-string gzip
, this function will encode the original response body into bytes in GZIP
format, and return to client.
For every request, if there is a condition(exception in other languages) signaled by the next
procedures, it will be catched by this middleware and converted to a response of HTTP code 500, and the backtrace of this condition as its HTTP body, send back to client.
For every request, if the value of header Content-Type
is recognized, then the body of incomming HTTP body will be parsed by a suitable parser. Now this middleware only support the following Content-Type:
- application/json
- application/x-www-form-urlencoded
For every request, if the path of it starts with a prefix specified in the configuration file's static-file section, this middleware will construct a path for file under directory static/
, return this pathname if exists, or respond 404 if file doesn't exist
- Home
- Getting Started
- Basic Usage
- Advanced Topics
- APIs
- eloquent.mvc.config
- eloquent.mvc.controller