0 purchases
ease http
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();
}
copied to clipboard
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');
}
copied to clipboard
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');
}
copied to clipboard
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');
}
copied to clipboard
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.