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 String id = generateDsiRequestId();
  options.extra[kDsiRequestIdExtraKey] = id;

  final CurlModel curlModel = CurlModel(
    id: id,
    url: options.uri,
    headers: Map<String, dynamic>.from(options.headers),
    body: options.data,
    requestSize: Utils.estimateSize(options.data),
    extra: options.extra,
    method: options.method,
    queryParameters: options.queryParameters,
    creationDate: DateTime.now(),
  );
  CurlLogs.instance.addItem(curlModel);
  super.onRequest(options, handler);
}