mercury_client 2.0.3 copy "mercury_client: ^2.0.3" to clipboard
mercury_client: ^2.0.3 copied to clipboard

outdated

Portable HTTP client (Browser and Native support) with memory cache and support for methods GET, POST, PUT, DELETE, PATCH and OPTIONS.

Mercury_Client #

pub package Null Safety

CI GitHub Tag New Commits Last Commits Pull Requests Code size License

Portable HTTP client (Browser and Native support) with memory cache.

Methods: #

  • GET
  • POST
  • PUT
  • DELETE
  • PATCH
  • OPTIONS.

Usage #

A simple usage example:

import 'package:mercury_client/mercury_client.dart';
import 'dart:async';

main() async {
  
  var client = HttpClient('http://gateway.your.domain/api-1');
  
  try {
    // Request with POST method:
    // URL: http://gateway.your.domain/api-1/call-foo?var=123
    // Content-Type: application/json
    // Body: { 'content': 'any' }
    var response = await client.post(
      'call-foo',
      parameters: {'var': '123'},
      body: "{ 'content': 'any' }",
      contentType: 'application/json',
    );

    if (response.isOK) {
      print(response.body);
    }
    
  } catch (e) {
    print('Error requesting URL: $e');
  }
  
}

HttpCache usage:

import 'package:mercury_client/mercury_client.dart';
import 'dart:async';

main() async {
  
  var client = HttpClient('http://gateway.your.domain/api-1') ;
  
  // HTTP Cache with max memory of 16M and timeout of 5min:
  var cache = HttpCache(1024*1024*16, 1000*60*5) ;

  try {
    var response = cache.getURL('http://host/path/to/base64/image.jpeg');

    if (response.isOK) {
      img.src = 'data:image/jpeg;base64,' + response.body;
    }
  }
  catch (e) {
    print('Error requesting URL: $e');
  }

}

Mercury (mythology) #

Mercury is known to the Romans as Mercurius.

He is the god of financial gain, commerce, eloquence, messages, communication (including divination), travelers, boundaries, luck, trickery and thieves.

Features and bugs #

Please file feature requests and bugs at the issue tracker.

Author #

Graciliano M. Passos: gmpassos@GitHub.

License #

Dart free & open-source license.

15
likes
0
pub points
75%
popularity

Publisher

unverified uploader

Portable HTTP client (Browser and Native support) with memory cache and support for methods GET, POST, PUT, DELETE, PATCH and OPTIONS.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

collection, enum_to_string, swiss_knife

More

Packages that depend on mercury_client