This module exposes a very simple middleware system.
Given a list of middleware functions, you can run them all in sequence by using the run function. Think of this
function as a reducer or folding function that will aggregate the transformations from all middlewares into a single
( response, command ) tuple.
let
middlewares =
[ flashMsgMiddleware, authMiddleware ]
in
( newResponse, newCmd ) =
run context request response middlewares
Middlewares are simple functions that will receive your application's context, a request and a response as parameters, and return a response and command. Remember that you can lock a response inside your middlewares. To better understand what is a locked response, please refer to the
Express.Responsemodule documentation.