rhttp_curl_logger 0.1.0+1
rhttp_curl_logger: ^0.1.0+1 copied to clipboard
An interceptor for rhttp that prints the request as a single line cURL command
rhttp_curl_logger #
A lightweight logger for the rhttp
package that prints requests as cURL
commands to your console for easy debugging and sharing.
π¦ Installation #
Add the package to your pubspec.yaml
:
dev_dependencies:
rhttp_curl_logger: ^0.1.0+1
π Usage #
Use the RhttpCurlLogger
interceptor in your rhttp
client:
import 'package:rhttp_curl_logger/rhttp_curl_logger.dart';
final client = await RhttpClient.create(
interceptors: [
RhttpCurlLogger(
useDoubleQuotes: true, // default
escapeQuotesInBody: true, // default
multiline: false, // default
logName: 'curl_log', // default
logger: null, // default
),
],
);
π§ͺ Example #
- Configuration:
final client = RHttpClient(
interceptors: [
RhttpCurlLogger(
multiline: true,
logName: 'rhttp',
useDoubleQuotes: false,
),
],
);
- Output sample:
[rhttp] curl -X POST
-H 'content-type: application/json'
-d '{"title":"foo","body":"bar","userId":1}'
'https://jsonplaceholder.typicode.com/posts?foo=bar&baz=1'
If you find this package helpful, consider giving it a π on pub.flutter-io.cn or sharing it with others.
For bugs, or feature requests, feel free to open an issue