http_extensions_protobuf 0.1.3 copy "http_extensions_protobuf: ^0.1.3" to clipboard
http_extensions_protobuf: ^0.1.3 copied to clipboard

outdated

An http extension that serializes requests body to protobuf and deserializes responses's content from protobuf.

example/example.dart

import 'package:http_extensions/http_extensions.dart';
import 'package:http_extensions_protobuf/http_extensions_protobuf.dart';
import 'package:logging/logging.dart';
import 'package:http/http.dart';

import 'hello.pb.dart';

main() async {
  // Displaying logs
  Logger.root.level = Level.ALL;
  Logger.root.onRecord.listen((record) {
    print('${record.level.name}: ${record.time}: ${record.message}');
  });

  final client = ExtendedClient(
    inner: Client(),
    extensions: [
      ProtobufExtension(logger: Logger("Cache")),
    ],
  );

  // The new request will get data and add it to cache
  final proto = ProtobufOptions(
    requestMessage: HelloRequest(),
    responseMessage: HelloReply(),
  );

  final response = await client.getWithOptions(
    "http://www.flutter.dev",
    options: [proto],
  );

  if (response.statusCode == 200) {
    print("Reply: ${proto.responseMessage}");
  }
}
5
likes
0
pub points
51%
popularity

Publisher

unverified uploader

An http extension that serializes requests body to protobuf and deserializes responses's content from protobuf.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

http, http_extensions, logging, meta, protobuf

More

Packages that depend on http_extensions_protobuf