http_extensions_base_url 1.0.0
http_extensions_base_url: ^1.0.0 copied to clipboard

An http extension that adds base url to requests with a relative path.

example/example.dart

import 'package:http_extensions/http_extensions.dart';
import 'package:http_extensions_base_url/http_extensions_base_url.dart';
import 'package:logging/logging.dart';
import 'package:http/http.dart';

void main() async {
  // Displaying logs
  Logger.root.level = Level.ALL;
  Logger.root.onRecord.listen((record) {
    print('${record.level.name}: ${record.time}: ${record.message}');
  });

  final client = ExtendedClient(
    inner: Client() as BaseClient,
    extensions: [
      BaseUrlExtension(
          logger: Logger('BaseUrl'),
          defaultOptions: BaseUrlOptions(url: Uri.parse('http://flutter.dev'))),
    ],
  );

  final response = await client.get(Uri.parse('/docs'));
  print('Html content: ${response.body}');
}
0
likes
120
pub points
53%
popularity

An http extension that adds base url to requests with a relative path.

Repository (GitHub)
View/report issues

Documentation

API reference

Uploader

alois.deniel@gmail.com

License

MIT (LICENSE)

Dependencies

http, http_extensions, logging, meta

More

Packages that depend on http_extensions_base_url