handle method
Implementation
@override
Future<DoxResponse> handle(DoxRequest req, Next next) async {
_Timings timings = _Timings();
Stopwatch watch = Stopwatch()..start();
DoxResponse res = await runZoned(
next,
zoneValues: <Object, Object>{_key: timings},
);
timings.add('total', watch.elapsed, null, own: true);
String value = timings.toHeader();
// keep a Server-Timing header that the app set itself
String key = header;
for (MapEntry<String, dynamic> entry in res.headers.entries) {
if (entry.key.toLowerCase() == 'server-timing') {
key = entry.key;
Object? old = entry.value;
String text = old is Iterable ? old.join(', ') : '$old';
if (text.isNotEmpty) value = '$text, $value';
}
}
return res.header(key, value);
}