Skip to content

Commit adf1d9a

Browse files
authored
feat(clientOption): enable pass interceptor as parameters (#149)
1 parent 8afe98d commit adf1d9a

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

helper/lib/src/client_options.dart

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import 'package:dio/dio.dart';
2+
13
/// Configuration options for the HTTP client.
24
final class ClientOptions {
35
/// The maximum duration to wait for a connection to establish before timing out.
@@ -15,16 +17,21 @@ final class ClientOptions {
1517
/// Custom logger for http operations.
1618
final Function(Object?)? logger;
1719

20+
/// List of Dio interceptors.
21+
/// Used only in case of using the default (dio) requester.
22+
final Iterable<Interceptor>? interceptors;
23+
1824
const ClientOptions({
1925
this.connectTimeout,
2026
this.writeTimeout,
2127
this.readTimeout,
2228
this.headers,
2329
this.logger,
30+
this.interceptors,
2431
});
2532

2633
@override
2734
String toString() {
28-
return 'ClientOptions{connectTimeout: $connectTimeout, writeTimeout: $writeTimeout, readTimeout: $readTimeout, headers: $headers, logger: $logger}';
35+
return 'ClientOptions{connectTimeout: $connectTimeout, writeTimeout: $writeTimeout, readTimeout: $readTimeout, headers: $headers, logger: $logger, interceptors: $interceptors}';
2936
}
3037
}

helper/lib/src/service/client_options.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ algolia.ClientOptions createClientOptions(ClientOptions? options) {
1111
readTimeout: options?.readTimeout ?? const Duration(seconds: 5),
1212
headers: options?.headers,
1313
logger: options?.logger,
14+
interceptors: options?.interceptors,
1415
agentSegments: [
1516
algolia.AgentSegment(
1617
value: 'algolia-helper-flutter',

0 commit comments

Comments
 (0)