jaguar_resty 2.8.18

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

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.8.8

  • Added RouteWithBody and getBody

2.8.5

  • OnSuccess, onFailure, run and isFailure for Response
  • onSuccess and onFailure for go

Breaking change

  • then positional argument is converted to named parameter in go

2.8.4

  • Added Patch

2.8.1-dev.2

  • Powerful After interceptor

2.8.1-dev.1

  • Class based Interceptor

2.8.1-dev.0

  • Fixed query bug when data is not string
  • Standardised setters in request creators

2.6.2

  • Dart 2 stable

2.5.16

  • Fixed query copying bug

2.5.15

  • Added BearerToken interceptor

2.5.12

  • pub fixes

2.5.9

  • Fixed bugs in go method

2.5.6

  • Dart2 bug fixes

2.5.4

  • Dart 2 bug fix

2.5.4

  • Dart 2 bug fixes

2.5.2

  • Casting bug fixes

2.5.1

  • Unified authority and path setter in constructors
  • Added setUrl method

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/example.dart

import 'dart:async';
import 'package:http/io_client.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(convert: Book.map));
  print(await resty
      .post('/book')
      .http('localhost:8000')
      .json(new Book(id: '4', name: 'Book4'))
      .list(convert: 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.8.18

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.8.18 Nov 13, 2018 Go to the documentation of jaguar_resty 2.8.18 Download jaguar_resty 2.8.18 archive
2.8.16 Nov 12, 2018 Go to the documentation of jaguar_resty 2.8.16 Download jaguar_resty 2.8.16 archive
2.8.15 Nov 12, 2018 Go to the documentation of jaguar_resty 2.8.15 Download jaguar_resty 2.8.15 archive
2.8.14 Nov 2, 2018 Go to the documentation of jaguar_resty 2.8.14 Download jaguar_resty 2.8.14 archive
2.8.12 Oct 30, 2018 Go to the documentation of jaguar_resty 2.8.12 Download jaguar_resty 2.8.12 archive
2.8.10 Oct 30, 2018 Go to the documentation of jaguar_resty 2.8.10 Download jaguar_resty 2.8.10 archive
2.8.9 Oct 29, 2018 Go to the documentation of jaguar_resty 2.8.9 Download jaguar_resty 2.8.9 archive
2.8.8 Sep 26, 2018 Go to the documentation of jaguar_resty 2.8.8 Download jaguar_resty 2.8.8 archive
2.8.6 Sep 18, 2018 Go to the documentation of jaguar_resty 2.8.6 Download jaguar_resty 2.8.6 archive
2.8.5 Sep 18, 2018 Go to the documentation of jaguar_resty 2.8.5 Download jaguar_resty 2.8.5 archive

All 61 versions...

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

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

  • Dart: 2.0.0
  • pana: 0.12.6

Platforms

Detected platforms: Flutter, other

Primary library: package:jaguar_resty/jaguar_resty.dart with components: io.

Health suggestions

Format lib/src/jaguar_resty_base.dart.

Run dartfmt to format lib/src/jaguar_resty_base.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.65 <3.0.0
async ^2.0.6 2.0.8
auth_header ^2.1.2 2.1.2
client_cookie ^2.1.6 2.1.6
collection ^1.14.6 1.14.11
http ^0.12.0 0.12.0
http_parser ^3.1.1 3.1.3
meta ^1.1.6 1.1.6
path ^1.6.2 1.6.2
Transitive dependencies
charcode 1.1.2
source_span 1.4.1
string_scanner 1.0.4
typed_data 1.1.6
Dev dependencies
jaguar ^2.2.20
test ^1.3.0