jaguar_resty 2.5.16

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

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.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/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.5.16"

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.5.16 Jul 11, 2018 Go to the documentation of jaguar_resty 2.5.16 Download jaguar_resty 2.5.16 archive
2.5.15 Jul 11, 2018 Go to the documentation of jaguar_resty 2.5.15 Download jaguar_resty 2.5.15 archive
2.5.14 Jul 8, 2018 Go to the documentation of jaguar_resty 2.5.14 Download jaguar_resty 2.5.14 archive
2.5.12 Jul 8, 2018 Go to the documentation of jaguar_resty 2.5.12 Download jaguar_resty 2.5.12 archive
2.5.10 Jun 29, 2018 Go to the documentation of jaguar_resty 2.5.10 Download jaguar_resty 2.5.10 archive
2.5.9 Jun 28, 2018 Go to the documentation of jaguar_resty 2.5.9 Download jaguar_resty 2.5.9 archive
2.5.8 Jun 28, 2018 Go to the documentation of jaguar_resty 2.5.8 Download jaguar_resty 2.5.8 archive
2.5.5 Jun 5, 2018 Go to the documentation of jaguar_resty 2.5.5 Download jaguar_resty 2.5.5 archive
2.5.4 Jun 5, 2018 Go to the documentation of jaguar_resty 2.5.4 Download jaguar_resty 2.5.4 archive
2.5.3 May 30, 2018 Go to the documentation of jaguar_resty 2.5.3 Download jaguar_resty 2.5.3 archive

All 41 versions...

Analysis

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

  • Dart: 2.0.0-dev.63.0
  • pana: 0.11.3

Scores

Popularity:
Describes how popular the package is relative to other packages. [more]
72 / 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]
86
Learn more about scoring.

Platforms

Detected platforms: Flutter, web, other

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

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.63.0 <3.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.10 1.14.10
http ^0.11.3 0.11.3+17
http_parser ^3.1.1 3.1.2
path ^1.6.1 1.6.1
Transitive dependencies
charcode 1.1.2
source_span 1.4.0
string_scanner 1.0.2
typed_data 1.1.5
Dev dependencies
jaguar ^2.1.8
test ^1.0.0