You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* refactor: initial v3.0.0 implementation
* feat: adds json extensions for convenience and example of body parsing to models
* fix: update changelog to match version
Copy file name to clipboardExpand all lines: CHANGELOG.md
+12Lines changed: 12 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,17 @@
1
1
# Changelog
2
2
3
+
## 3.0.0
4
+
5
+
-**Breaking**: Rebuild from scratch. Not backwards compatible with 2.x.
6
+
-**Added**: `HttpInterceptor` interface (replaces `InterceptorContract`). Same four methods with `FutureOr` support.
7
+
-**Added**: `InterceptedClient.build(...)` and `InterceptedHttp.build(...)` with `interceptors`, `client`, `retryPolicy`, `requestTimeout`, `onRequestTimeout`.
8
+
-**Added**: Optional `params` and `paramsAll` on `get`, `post`, `put`, `patch`, `delete`, `head`; merged into URL query.
@@ -18,7 +18,7 @@ This is a plugin that lets you intercept the different requests and responses fr
18
18
19
19
## Quick Reference
20
20
21
-
**Already using `http_interceptor`? Check out the [1.0.0 migration guide](./guides/migration_guide_1.0.0.md) for quick reference on the changes made and how to migrate your code.**
21
+
**Upgrading from 2.x? See the [3.0.0 migration guide](./guides/migration_guide_3.0.0.md).**
22
22
23
23
-[http\_interceptor](#http_interceptor)
24
24
-[Quick Reference](#quick-reference)
@@ -29,6 +29,8 @@ This is a plugin that lets you intercept the different requests and responses fr
29
29
-[Using your interceptor](#using-your-interceptor)
30
30
-[Using interceptors with Client](#using-interceptors-with-client)
31
31
-[Using interceptors without Client](#using-interceptors-without-client)
32
+
-[Working with JSON responses](#working-with-json-responses)
33
+
-[Decoding responses into models](#decoding-responses-into-models)
32
34
-[Retrying requests](#retrying-requests)
33
35
-[Using self signed certificates](#using-self-signed-certificates)
34
36
-[InterceptedClient](#interceptedclient)
@@ -51,7 +53,8 @@ http_interceptor: <latest>
51
53
- 🚦 Intercept & change unstreamed requests and responses.
52
54
- ✨ Retrying requests when an error occurs or when the response does not match the desired (useful for handling custom error responses).
53
55
- 👓 `GET` requests with separated parameters.
54
-
- ⚡️ Standard `bodyBytes` on `ResponseData` to encode or decode in the desired format.
56
+
- ⚡️ Standard `Response.bodyBytes` for encoding or decoding as needed.
57
+
- 📦 Convenience helpers to decode JSON responses and map them into your own models.
55
58
- 🙌🏼 Array parameters on requests.
56
59
- 🖋 Supports self-signed certificates (except on Flutter Web).
57
60
- 🍦 Compatible with vanilla Dart projects or Flutter projects.
In order to implement `http_interceptor` you need to implement the `InterceptorContract` and create your own interceptor. This abstract class has four methods:
73
+
Implement `HttpInterceptor` to add logging, headers, error handling, and more. The interface has four methods:
71
74
72
-
-`interceptRequest`, which triggers before the http request is called
73
-
-`interceptResponse`, which triggers after the request is called, it has a response attached to it which the corresponding to said request;
74
-
75
-
-`shouldInterceptRequest` and `shouldInterceptResponse`, which are used to determine if the request or response should be intercepted or not. These two methods are optional as they return `true` by default, but they can be useful if you want to conditionally intercept requests or responses based on certain criteria.
75
+
-**interceptRequest** – runs before the request is sent. Return the (possibly modified) request.
76
+
-**interceptResponse** – runs after the response is received. Return the (possibly modified) response.
77
+
-**shouldInterceptRequest** / **shouldInterceptResponse** – return `false` to skip interception for that request/response (default `true`).
76
78
77
-
You could use this package to do logging, adding headers, error handling, or many other cool stuff. It is important to note that after you proccess the request/response objects you need to return them so that `http` can continue the execute.
79
+
All methods support `FutureOr` so you can use sync or async. Modify the request/response in place and return it, or return a new instance.
78
80
79
-
All four methods use `FutureOr` syntax, which makes it easier to support both synchronous and asynchronous behaviors.
80
-
81
-
- Logging with interceptor:
81
+
- Logging interceptor:
82
82
83
83
```dart
84
-
class LoggerInterceptor extends InterceptorContract {
84
+
class LoggerInterceptor implements HttpInterceptor {
<!-- Explain the overall context of the decision, the problem it attempts to solve, examples of why it might need solving. You can even add possible solutions -->
11
+
12
+
## Decision
13
+
14
+
<!-- Explain the decision that was taken. Why it was taken -->
15
+
16
+
## Consequences
17
+
18
+
<!-- Describe the consequences of this decision, deprecations, new features, removed code, etc. -->
0 commit comments