NextMiddlewareFunction typedef
NextMiddlewareFunction =
FutureOr Function(DoxRequest req, Next next)
A function middleware that runs code before and after the controller.
Future<DoxResponse> timer(DoxRequest req, Next next) async {
Stopwatch watch = Stopwatch()..start();
DoxResponse res = await next();
return res.header('X-Time', '${watch.elapsedMilliseconds}ms');
}
Implementation
typedef NextMiddlewareFunction = FutureOr<dynamic> Function(
DoxRequest req,
Next next,
);