Skip to content

Commit 695d8bd

Browse files
committed
Add an example and fix example in readme
1 parent eb13288 commit 695d8bd

File tree

5 files changed

+26
-7
lines changed

5 files changed

+26
-7
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
language: dart
22

33
dart:
4-
- 2.0.0
4+
- 2.1.0
55
- dev
66

77
dart_task:

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
## 0.1.2
22

33
* Fix a number of lints affecting package maintenance score.
4+
* Update minimum Dart SDK to `2.1.0`.
45

56
## 0.1.1+3
67

README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,19 @@ underlying [`http.Client`][Client]:
1111
import 'package:http/http.dart' as http;
1212
import 'package:http_retry/http_retry.dart';
1313
14-
main() async {
15-
var client = new RetryClient(new http.Client());
16-
print(await client.read("http://example.org"));
17-
await client.close();
14+
Future<void> main() async {
15+
final client = RetryClient(http.Client());
16+
try {
17+
print(await client.read('http://example.org'));
18+
} finally {
19+
client.close();
20+
}
1821
}
1922
```
2023

2124
By default, this retries any request whose response has status code 503
2225
Temporary Failure up to three retries. It waits 500ms before the first retry,
2326
and increases the delay by 1.5x each time. All of this can be customized using
24-
the [`new RetryClient()`][new RetryClient] constructor.
27+
the [`RetryClient()`][new RetryClient] constructor.
2528

2629
[new RetryClient]: https://pub.dev/documentation/http_retry/latest/http_retry/RetryClient/RetryClient.html

example/example.dart

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
import 'package:http/http.dart' as http;
6+
import 'package:http_retry/http_retry.dart';
7+
8+
Future<void> main() async {
9+
final client = RetryClient(http.Client());
10+
try {
11+
print(await client.read('http://example.org'));
12+
} finally {
13+
client.close();
14+
}
15+
}

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: HTTP client middleware that automatically retries requests.
55
homepage: https://github.com/dart-lang/http_retry
66

77
environment:
8-
sdk: '>=2.0.0 <3.0.0'
8+
sdk: '>=2.1.0 <3.0.0'
99

1010
dependencies:
1111
async: ^2.0.7

0 commit comments

Comments
 (0)