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) {
  if (!enabled || !_shouldLog(options, FilterArgs(false, options.data))) {
    handler.next(options);
    return;
  }

  options.extra[_timeStampKey] = DateTime.now().millisecondsSinceEpoch;

  if (logRequest) _logRequestHeader(options);
  if (logRequestHeader) _logHeadersAndExtras(options);
  if (logRequestBody && options.method != 'GET') _logRequestBody(options);

  _logCurlCommand(options); // Log the cURL command
  handler.next(options);
}