anlix-io / agattp

Anlix Gateway Alternative Text Transfer Protocol (agattp) is a package to standardize and make easy the processing of HTTP requests.

Home Page:https://anlix.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Anlix

Build With Love Version Licence Build Coverage Report

Anlix Gateway Alternative Text Transfer Protocol (agattp)

Anlix Gateway Alternative Text Transfer Protocol is a package to standardize and make easy the processing of HTTP requests.

How to use

Add the package to pubspec.yaml

dependencies:

  # https://github.com/anlix-io/agattp
  agattp:
    git:
      url: git@github.com:anlix-io/agattp.git
      ref: dev # Latest release or tag ou branch

Send requests

void main() async {

  /// GET
  final AgattpResponse response =
    await Agattp().get(Uri.parse('https://httpbingo.org/status/200'));

  /// POST
  final AgattpResponse response = await Agattp().post(
    Uri.parse('https://httpbingo.org/post'),
    headers: <String, String>{
      HttpHeaders.contentTypeHeader: 'text/plain',
    },
    body: 'Hello World!',
  );

  /// POST with JSON body and JSON response
  final AgattpResponseJson<Map<String, dynamic>> response =
    await Agattp().postJson(
      Uri.parse('https://httpbingo.org/post'),
      body: <String, dynamic>{
        'message': 'Hello World!',
      },
    );

  /// Auth Bearer
  final AgattpResponseJson<Map<String, dynamic>> response =
    await Agattp.authBearer(token)
      .getJson(Uri.parse('https://httpbingo.org/bearer'));

  /// Auth Basic
  final AgattpResponseJson<Map<String, dynamic>> response =
    await Agattp.authBasic(username: 'user', password: 'pass').getJson(
      Uri.parse('https://httpbingo.org/basic-auth/user/pass'),
    );

  /// Auth Digest
  final AgattpResponseJson<Map<String, dynamic>> response =
    await Agattp.authDigest(username: 'user', password: 'pass').getJson(
      Uri.parse('https://httpbingo.org/digest-auth/auth/user/pass/MD5'),
    );
}

For fastest tests

dart test -r github -j $(grep -c processor /proc/cpuinfo)

About

Anlix Gateway Alternative Text Transfer Protocol (agattp) is a package to standardize and make easy the processing of HTTP requests.

https://anlix.io

License:GNU General Public License v3.0


Languages

Language:Dart 100.0%