requester 1.0.0 copy "requester: ^1.0.0" to clipboard
requester: ^1.0.0 copied to clipboard

discontinued

Provides a middlware API for package:http

requester #

Send package:http requests with middleware

example #

import 'dart:async';
import 'package:requester/requester.dart';
import 'package:http/http.dart';

Future main() async {
  var client = new Client();
  var requester = new Requester(client);
  requester.addMiddleware(new LoggingMiddleware());
  var request = new HackernewsRequest("dart");
  await requester.send(request);
  print('done!');
}

class HackernewsRequest extends Request {
  HackernewsRequest(String query)
      : super("GET",
            Uri.parse("http://hn.algolia.com/api/v1/search?query=$query")) {
    this.headers['Content-Type'] = 'application/json';
  }
}

// response:
//   ╭--- cURL (http://hn.algolia.com/api/v1/search?query=dart)
//   curl -X GET -H "Content-Type: application/json" http://hn.algolia.com/api/v1/search?query=dart
//   ╰--- (copy and paste the above line to a terminal)
//   Response: 200
//   {"hits":[{"created_at":"2011-10-10T07:03:34.000Z" ...
//   done!

see the full example in the /example directory.

0
likes
30
pub points
0%
popularity

Publisher

verified publisherjpryan.me

Provides a middlware API for package:http

Repository (GitHub)
View/report issues

License

BSD-2-Clause (LICENSE)

Dependencies

http

More

Packages that depend on requester