roundtripper 0.3.1 copy "roundtripper: ^0.3.1" to clipboard
roundtripper: ^0.3.1 copied to clipboard

outdated

another composable, Future-based library for making HTTP requests

Another composable, multi-platform HTTP client

pub package ci

Totally inspected by http.RoundTripper from golang, and dart style fit. Based on dio for crossing-platforms support.

You could do any processing for each request in RoundTrip.

  • Logging.
  • Throws non-2xx Response as Error.
  • Request/Response Body Encoding.

Using #

import 'package:roundtripper/roundtripper.dart';
import 'package:roundtripper/roundtripbuilders/request_body_convert.dart';
import 'package:roundtripper/roundtripbuilders/request_log.dart';
import 'package:roundtripper/roundtripbuilders/throws_not_2xx_error.dart';

var c = Client(roundTripBuilders: [
  ThrowsNot2xxError(),
  RequestBodyConvert(),
  RequestLog(logger),
]);

void main() async {
  var resp = await c.fetch(Request.uri(
    "$httpBinEndpoint/anything",
    queryParameters: {
      "int": 1,
      "slice": [1, 2],
    },
    headers: {
      "x-int": 1,
      "x-slice": [1, 2],
    },
  ));

  try {
    var json = await resp.json();
  } on ErrorResponse catch (e) {
    // e.response
  }
}
0
likes
0
pub points
0%
popularity

Publisher

verified publisherpub.v42.one

another composable, Future-based library for making HTTP requests

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

contextdart, dio, freezed_annotation, http_parser, logr

More

Packages that depend on roundtripper