Middleware sits between
Backend objects, using hooks for
Response processing according to
frontier data flow.
It’s a light, low-level system for filtering and altering Frontier’s requests and responses.
Activating a middleware¶
To activate a
Middleware component, add it to the
MIDDLEWARES setting, which is a list whose values can be class paths or instances of
Here’s an example:
MIDDLEWARES = [ 'frontera.contrib.middlewares.domain.DomainMiddleware', ]
Middlewares are called in the same order they’ve been defined in the list, to decide which order to assign to your middleware pick a value according to where you want to insert it. The order does matter because each middleware performs a different action and your middleware could depend on some previous (or subsequent) middleware being applied.
Finally, keep in mind that some middlewares may need to be enabled through a particular setting. See each middleware documentation for more info.
Writing your own middleware¶
Writing your own frontier middleware is easy. Each
component is a single Python class inherited from
FrontierManager will communicate with all active middlewares
through the methods described below.
Built-in middleware reference¶
This page describes all
Middleware components that come with Frontera.
For information on how to use them and how to write your own middleware, see the
middleware usage guide..
For a list of the components enabled by default (and their orders) see the