onRequest method

  1. @override
void onRequest(
  1. RequestOptions options,
  2. RequestInterceptorHandler handler
)

Called when the request is about to be sent.

Implementation

@override
void onRequest(RequestOptions options, RequestInterceptorHandler handler) {
  final id = _logger.logRequest(
    method: options.method,
    url: options.uri.toString(),
    headers: options.headers.map((k, v) => MapEntry(k, v.toString())),
    body: options.data,
  );
  _requestIds[options] = id;
  _requestStarts[options] = DateTime.now();
  handler.next(options);
}