ease_http 0.1.8 copy "ease_http: ^0.1.8" to clipboard
ease_http: ^0.1.8 copied to clipboard

Based on Dart http package, makes http package more powerful and easier to use.

About #

Based on Dart http package, makes http package more powerful and easier to use.

Features #

Typed response #

Use HttpClient:

import 'package:ease_http/ease_http.dart';

void main() async {
  final client = HttpClient();

  // response is typed.
  final response = await client.get<Map<String, dynamic>>('http://example.com');
  client.close();
}

Use SingleRequest:

import 'package:ease_http/ease_http.dart';

void main() async {
  final request = SingleRequest();

  // response is typed.
  final response = await request.get<Map<String, dynamic>>('http://example.com');
}

Endpoint mapping #

void main() async {
  final request = SingleRequest(endpointMap: {
    'api_1': 'http://example1.com',
    'api_2': 'http://example2.com',
  });

  final response = await request.get<String>('api_1:foo');
}

Build headers on the fly #

void main() async {
  final request = SingleRequest(
    endpointMap: {
      'api_1': 'http://example1.com',
      'api_2': 'http://example2.com',
    },
    headersBuilder: (request) async {
      if (request.endpointName == 'api_1') {
        return {
          'Authorization': 'accessToken',
          ...request.headers,
        };
      } else {
        return request.headers;
      }
    },
  );

  final result = await request.get<String>('api_1:foo');
}
0
likes
140
pub points
16%
popularity

Publisher

verified publisherhanlogy.com

Based on Dart http package, makes http package more powerful and easier to use.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (LICENSE)

Dependencies

http, http_parser

More

Packages that depend on ease_http