Skip to content

OnClickListener2048/curl_dio_logger_interceptor

Repository files navigation

curl_dio_logger_interceptor

Pub

Language: English | 简体中文

Convert dio request into a cURL command.

Get started

Install

Add the curl_dio_logger_interceptor package to your pubspec dependencies.

Super simple to use

import 'package:curl_dio_logger_interceptor/curl_dio_logger_interceptor.dart';
  Dio dio = Dio();
  dio.interceptors.add(CurlDioLoggerInterceptor(
    needResponseHeader: true));

then you will get something like this

curl -X GET "https://httpbin.org/get?name=watson&foo=bar" -i --header "key1: value1" --header "key2: value2" --header "key3: value3"

full use parameter

  /**
   * 是否打印出服务器回应的 HTTP 标头。
   * English: Print the server response HTTP headers.
   */
  bool needResponseHeader;
  /**
   * 是否在请求开始前打印出 curl 命令。
   * English: Print the curl command before the request starts.
   */
  bool printOnRequest = false;
  /**
   * 是否忽略长参数。
   * English: Whether to ignore long parameters.
   */
  bool ignoreLongParam = true;
  /**
   * 忽略长参数的长度。
   * English: The length of the long parameter to be ignored.
   */
  int ignoreLongParamLength = 1024;
  /**
   * 额外的参数。
   * English: Additional parameters.
   */
  List<String>? extraParams = [];
  /**
   * 打印日志的方法。
   * English: The method to print logs.
   */
  void Function(Object object) logPrint;

About

covert dio request to a cURL command line

Resources

License

Stars

Watchers

Forks

Packages

No packages published