jaguar_resty 2.4.3

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 70

jaguar_resty

Build fluent functional Restful clients

Features

  • Fluent API to set:
    • Hierarchical paths
      • get('http://localhost:8080', '/api/book/${id}').go()
      • get('api').path('book').path(id).go()
    • Query parameters
      • get('/books').query('page', '2').list()
    • Headers
      • get('/book').header('page', '2').list()
    • Body
      • post('/book').json(Book('1', 'Harry potter')).one()
  • JSON request encoding
    • post('/book').json(Book('1', 'Harry potter')).one()
  • JSON request decoding
    • get('/book/1').one(Book.map)
  • URL encoded forms
  • Multipart form
  • Cookie jar
    • get('/data').interceptBefore(jar.intercept).go()
  • Interceptors
    • get('/data').interceptBefore(jar.intercept).go()
  • Authenticators

Changelog

2.4.2

  • Exposed parseMimeType and parseEncoding

2.4.1

  • Simpler one, List, decode and decodeList methods

2.3.6

  • Success hooks on Response

2.3.5

  • Success hooks

2.3.4

  • Support for authorization headers

2.3.3

  • Exposed headerMap and queryMap

2.3.2

  • Added urlEncodedForm to Put

2.3.1

  • Renamed authority to origin

2.2.2

  • Added options convenience function

2.2.1

  • go gets an optional then callback
  • Added OptionsMethod

2.1.3

  • Bug fixes

2.1.2

  • CookieJar's interceptor method renamed to intercept

2.1.1

  • Renamed fetchResponse to go
  • Renamed fetch to one
  • Renamed fetchList to List

1.1.3

  • authority bug fix

1.1.2

  • Multipart forms
  • Simultaneous authority and path definition

example/jaguar_resty_example.dart

import 'dart:async';
import 'package:http/http.dart' as ht;
import 'package:jaguar_resty/jaguar_resty.dart' as resty;
import 'package:jaguar/jaguar.dart';

class Book {
  String id;

  String name;

  Book({this.id, this.name});

  static Book map(Map map) => new Book()..fromMap(map);

  Map toJson() => {
        'id': id,
        'name': name,
      };

  void fromMap(Map map) => this
    ..id = map['id']
    ..name = map['name'];

  String toString() => toJson().toString();
}

final books = <Book>[
  new Book(id: '1', name: 'Harry potter'),
  new Book(id: '2', name: 'Da Vinci code'),
  new Book(id: '3', name: 'Angels and deamons'),
];

final server = new Jaguar(port: 8000)
  ..getJson(
      '/book/:id',
      (Context ctx) => books.firstWhere((b) => b.id == ctx.pathParams['id'],
          orElse: () => null))
  ..postJson('/book', (Context ctx) async {
    books.add(await ctx.bodyAsJson(convert: Book.map));
    return books;
  });

Future client() async {
  print(await resty.get('/book/1').http('localhost:8000').one(Book.map));
  print(await resty
      .post('/book')
      .http('localhost:8000')
      .json(new Book(id: '4', name: 'Book4'))
      .list(Book.map));
}

main() async {
  resty.globalClient = new ht.IOClient();

  await server.serve(logRequests: true);

  await client();
  await server.close();
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  jaguar_resty: "^2.4.3"

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


      import 'package:jaguar_resty/jaguar_resty.dart';
  
Version Uploaded Documentation Archive
2.4.3 May 21, 2018 Go to the documentation of jaguar_resty 2.4.3 Download jaguar_resty 2.4.3 archive
2.4.2 May 19, 2018 Go to the documentation of jaguar_resty 2.4.2 Download jaguar_resty 2.4.2 archive
2.4.1 May 19, 2018 Go to the documentation of jaguar_resty 2.4.1 Download jaguar_resty 2.4.1 archive
2.3.6 May 19, 2018 Go to the documentation of jaguar_resty 2.3.6 Download jaguar_resty 2.3.6 archive
2.3.5 May 19, 2018 Go to the documentation of jaguar_resty 2.3.5 Download jaguar_resty 2.3.5 archive
2.3.4 May 19, 2018 Go to the documentation of jaguar_resty 2.3.4 Download jaguar_resty 2.3.4 archive
2.3.3 May 19, 2018 Go to the documentation of jaguar_resty 2.3.3 Download jaguar_resty 2.3.3 archive
2.3.2 May 18, 2018 Go to the documentation of jaguar_resty 2.3.2 Download jaguar_resty 2.3.2 archive
2.3.1 May 18, 2018 Go to the documentation of jaguar_resty 2.3.1 Download jaguar_resty 2.3.1 archive
2.2.2 May 18, 2018 Go to the documentation of jaguar_resty 2.2.2 Download jaguar_resty 2.2.2 archive

All 29 versions...

Analysis

We analyzed this package on May 22, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.54.0
  • pana: 0.11.1

Scores

Popularity:
Describes how popular the package is relative to other packages. [more]
40 / 100
Health:
Code health derived from static analysis. [more]
100 / 100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100 / 100
Overall score:
Weighted score of the above. [more]
70
Learn more about scoring.

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:jaguar_resty/jaguar_resty.dart.

Suggestions

  • The description is too short.

    Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.20.1 <2.0.0
async ^2.0.6 2.0.7
auth_header ^0.0.3 0.0.3
client_cookie ^2.1.2 2.1.2
collection ^1.14.6 1.14.9
http ^0.11.3 0.11.3+16
http_parser ^3.1.1 3.1.2
Transitive dependencies
charcode 1.1.1
path 1.5.1
source_span 1.4.0
string_scanner 1.0.2
typed_data 1.1.5
Dev dependencies
jaguar ^2.0.1
test ^0.12.0