Skip to content

Commit 3d6e3dd

Browse files
authored
Allow custom parser (#49)
1 parent af81a84 commit 3d6e3dd

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

lib/src/client.dart

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@ typedef http.Client HttpClientFactory();
1616
class JsonApiClient {
1717
static const contentType = 'application/vnd.api+json';
1818

19-
final JsonApiParser _parser = const JsonApiParser();
19+
final JsonApiParser _parser;
2020

2121
final HttpClientFactory _factory;
2222

2323
/// JSON:API client uses Dart's native Http Client internally.
24-
/// To customize its behavior you can pass the [factory] function.
25-
const JsonApiClient({HttpClientFactory factory})
26-
: _factory = factory ?? _defaultFactory;
24+
/// To customize its behavior you can pass the [factory] function and the [parser].
25+
const JsonApiClient({HttpClientFactory factory, JsonApiParser parser})
26+
: _factory = factory ?? _defaultFactory,
27+
_parser = parser ?? const JsonApiParser();
2728

2829
/// Fetches a resource collection by sending a GET request to the [uri].
2930
/// Use [headers] to pass extra HTTP headers.

0 commit comments

Comments
 (0)