Anlix Gateway Alternative Text Transfer Protocol is a package to standardize and make easy the processing of HTTP requests.
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
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'),
);
}
dart test -r github -j $(grep -c processor /proc/cpuinfo)