-
Notifications
You must be signed in to change notification settings - Fork 21
feat(dart): add algolia_chopper_requester package #3291
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
techouse
wants to merge
63
commits into
algolia:main
Choose a base branch
from
techouse:feat/add-chopper-requester-package
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
63 commits
Select commit
Hold shift + click to select a range
d19989b
feat(dart): export AlgoliaAgent from algolia_client_core package
techouse 1a8bcf3
feat(dart): add algolia_chopper_requester package
techouse 47ef5f6
feat(dart): add algolia_chopper_requester package
techouse f7ad718
feat(dart): remove chopper_requester/CHANGELOG.md
techouse f47674e
feat(dart): update chopper_requester/README.md
techouse 0e3c6ec
feat(dart): remove chopper_requester/analysis_options.yaml
techouse 28cd141
feat(dart): remove chopper_requester/LICENSE
techouse aab0906
feat(dart): sync chopper_requester/lib/src/version.dart
techouse d812167
feat(dart): add license generation
techouse c5fd54c
feat(dart): add option to pass custom JsonConverter to ChopperRequest…
techouse 40cf261
feat(dart): fix docs
techouse 5a6598d
Merge branch 'main' into feat/add-chopper-requester-package
techouse 82f7bca
Merge branch 'main' into feat/add-chopper-requester-package
techouse 84a7bb5
Merge branch 'main' into feat/add-chopper-requester-package
techouse baa53ff
Merge branch 'main' into feat/add-chopper-requester-package
techouse 6d35059
Merge branch 'main' into feat/add-chopper-requester-package
techouse 33d1431
Merge branch 'main' into feat/add-chopper-requester-package
techouse 5ba830c
Merge branch 'main' into feat/add-chopper-requester-package
techouse 1e0e7da
Merge branch 'main' into feat/add-chopper-requester-package
techouse 812b937
Merge branch 'main' into feat/add-chopper-requester-package
techouse f0a6e4f
feat(dart): fix URL construction
techouse 57dcfa0
feat(dart): explicitly set empty Uri as baseUri
techouse 37585fc
Merge branch 'main' into feat/add-chopper-requester-package
techouse 8b2a51d
feat(dart): bump algolia_client_core
techouse a9083e9
Merge remote-tracking branch 'origin/feat/add-chopper-requester-packa…
techouse 00ba8c4
feat(dart): downgrade test
techouse 59329cd
feat(dart): bump version
techouse cdbaf2e
feat(dart): fix requestUri
techouse 2148ec0
feat(dart): add example
techouse 9d25176
feat(dart): update example
techouse 5e627e2
feat(dart): update example
techouse 581cee8
feat(dart): update example
techouse 14fc833
Merge branch 'main' into feat/add-chopper-requester-package
techouse 7c53cd3
Merge branch 'main' into feat/add-chopper-requester-package
shortcuts 95f4e19
Merge branch 'main' into feat/add-chopper-requester-package
techouse b2cc8f6
Merge branch 'main' into feat/add-chopper-requester-package
techouse 23a57ae
Merge branch 'main' into feat/add-chopper-requester-package
techouse 039a207
Merge branch 'main' into feat/add-chopper-requester-package
techouse 7bd6833
Merge branch 'main' into feat/add-chopper-requester-package
techouse 17e3cd9
Merge branch 'main' into feat/add-chopper-requester-package
techouse 1d55178
Merge branch 'main' into feat/add-chopper-requester-package
techouse f853813
Merge remote-tracking branch 'origin/main' into feat/add-chopper-requ…
techouse 1cb13bf
Merge branch 'main' into feat/add-chopper-requester-package
techouse ebc76f9
feat(dart): implement setClientApiKey
techouse fbe6121
Merge branch 'main' into feat/add-chopper-requester-package
techouse a97061a
Merge branch 'main' into feat/add-chopper-requester-package
techouse c417ec0
Merge branch 'main' into feat/add-chopper-requester-package
techouse c4978ad
Merge branch 'main' into feat/add-chopper-requester-package
techouse cbac9ab
Merge branch 'main' into feat/add-chopper-requester-package
techouse e68daac
Merge branch 'main' into feat/add-chopper-requester-package
techouse 0463079
Merge branch 'main' into feat/add-chopper-requester-package
techouse 386f5a9
Merge branch 'main' into feat/add-chopper-requester-package
techouse e4db547
Merge branch 'main' into feat/add-chopper-requester-package
techouse ca2363c
Merge branch 'main' into feat/add-chopper-requester-package
techouse 7477c01
Merge branch 'algolia:main' into feat/add-chopper-requester-package
techouse b5fab80
Update chopper_requester.dart
techouse 4160e1d
Merge branch 'main' into feat/add-chopper-requester-package
techouse 45f0f3b
Merge branch 'main' into feat/add-chopper-requester-package
techouse 2607674
Merge branch 'main' into feat/add-chopper-requester-package
techouse fbd6b5d
Merge branch 'main' into feat/add-chopper-requester-package
techouse f07babe
Merge branch 'algolia:main' into feat/add-chopper-requester-package
techouse 5e07da4
Merge branch 'main' into feat/add-chopper-requester-package
techouse 3ed1e91
feat(dart): add connectTimeout getter and setter to ChopperClient
techouse File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
clients/algoliasearch-client-dart/packages/chopper_requester/.gitignore
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# https://dart.dev/guides/libraries/private-files | ||
# Created by `dart pub` | ||
.dart_tool/ |
3 changes: 3 additions & 0 deletions
3
clients/algoliasearch-client-dart/packages/chopper_requester/CHANGELOG.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## 1.0.0 | ||
|
||
- Initial version. |
21 changes: 21 additions & 0 deletions
21
clients/algoliasearch-client-dart/packages/chopper_requester/LICENSE
techouse marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 Klemen Tusar | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
117 changes: 117 additions & 0 deletions
117
clients/algoliasearch-client-dart/packages/chopper_requester/README.md
techouse marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
# Chopper Requester for Algolia Search Client | ||
|
||
## 💡 Installation | ||
|
||
Add Algolia Client Core as a dependency in your project directly from pub.dev: | ||
techouse marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
#### For Dart projects: | ||
|
||
```shell | ||
dart pub add algolia_chopper_requester | ||
``` | ||
|
||
#### For Flutter projects: | ||
|
||
```shell | ||
flutter pub add algolia_chopper_requester | ||
``` | ||
|
||
### Basic Usage | ||
|
||
```dart | ||
final String appId = 'latency'; | ||
final String apiKey = '6be0576ff61c053d5f9a3225e2a90f76'; | ||
|
||
final SearchClient _client = SearchClient( | ||
appId: appId, | ||
apiKey: apiKey, | ||
options: ClientOptions( | ||
requester: ChopperRequester( | ||
appId: appId, | ||
apiKey: apiKey, | ||
) | ||
), | ||
); | ||
|
||
Future<SearchResponse> search(String query) => _client.searchIndex( | ||
request: SearchForHits( | ||
indexName: 'flutter', | ||
query: query, | ||
hitsPerPage: 5, | ||
), | ||
); | ||
``` | ||
|
||
You can configure the `ChopperRequester` with the following parameters: | ||
|
||
### Configuration | ||
|
||
```dart | ||
final requester = ChopperRequester({ | ||
/// Your Algolia Application ID | ||
required String appId, | ||
/// Your Algolia Search-Only API Key | ||
required String apiKey, | ||
/// Additional headers to send with the request | ||
Map<String, dynamic>? headers, | ||
/// The segments to include in the `User-Agent` header | ||
Iterable<AgentSegment>? clientSegments, | ||
/// The logger to use for debugging | ||
Logger? logger, | ||
/// The Chopper Interceptors to use for modifying the request | ||
Iterable<Interceptor>? interceptors, | ||
/// The HTTP client to use for sending requests | ||
Client? client | ||
}); | ||
``` | ||
|
||
### Advanced Usage | ||
|
||
To set the connect timeout one has to do that directly on the `Client`, i.e. | ||
|
||
```dart | ||
final requester = ChopperRequester( | ||
appId: appId, | ||
apiKey: apiKey, | ||
client: http.IOClient( | ||
HttpClient()..connectionTimeout = const Duration(seconds: 60), | ||
), | ||
); | ||
``` | ||
|
||
### Custom Interceptors | ||
|
||
For interceptors please see the [Chopper documentation](https://hadrien-lejard.gitbook.io/chopper/interceptors). | ||
|
||
### Custom Clients | ||
|
||
Via the `client` option users can use platform specific HTTP clients such: | ||
- [cronet_http](https://pub.dev/packages/cronet_http) on Android | ||
```dart | ||
final requester = ChopperRequester( | ||
appId: appId, | ||
apiKey: apiKey, | ||
client: CronetClient.fromCronetEngine( | ||
CronetEngine.build( | ||
cacheMode: CacheMode.memory, | ||
cacheMaxSize: 50 * 1024 * 1024, | ||
), | ||
closeEngine: true, | ||
), | ||
); | ||
``` | ||
- [cupertino_http](https://pub.dev/packages/cupertino_http) on iOS/macOS | ||
```dart | ||
final requester = ChopperRequester( | ||
appId: appId, | ||
apiKey: apiKey, | ||
client: CupertinoClient.fromSessionConfiguration( | ||
(URLSessionConfiguration.defaultSessionConfiguration() | ||
..timeoutIntervalForRequest = const Duration(seconds: 30)), | ||
), | ||
); | ||
``` | ||
|
||
## License | ||
|
||
Chopper Requester for Algolia Search Client is an open-sourced software licensed under the [MIT license](LICENSE). |
1 change: 1 addition & 0 deletions
1
clients/algoliasearch-client-dart/packages/chopper_requester/analysis_options.yaml
techouse marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include: package:lints/recommended.yaml |
4 changes: 4 additions & 0 deletions
4
...s/algoliasearch-client-dart/packages/chopper_requester/lib/algolia_chopper_requester.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
library algolia_chopper_requester; | ||
|
||
export 'package:chopper/chopper.dart' show Interceptor; | ||
export 'src/chopper_requester.dart'; |
21 changes: 21 additions & 0 deletions
21
clients/algoliasearch-client-dart/packages/chopper_requester/lib/src/agent_interceptor.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import 'dart:async' show FutureOr; | ||
|
||
import 'package:algolia_client_core/algolia_client_core.dart' show AlgoliaAgent; | ||
import 'package:chopper/chopper.dart'; | ||
import 'package:algolia_chopper_requester/src/platform/platform.dart'; | ||
|
||
/// Interceptor that attaches the Algolia agent to outgoing requests. | ||
/// | ||
/// This interceptor modifies the query parameters of each request to include the | ||
/// formatted representation of the Algolia agent. | ||
class AgentInterceptor implements Interceptor { | ||
/// The Algolia agent to be attached to outgoing requests. | ||
final AlgoliaAgent agent; | ||
|
||
/// Constructs an [AgentInterceptor] with the provided Algolia agent. | ||
const AgentInterceptor({required this.agent}); | ||
|
||
@override | ||
FutureOr<Response<BodyType>> intercept<BodyType>(Chain<BodyType> chain) => | ||
chain.proceed(Platform.algoliaAgent<BodyType>(chain, agent.formatted())); | ||
} |
33 changes: 33 additions & 0 deletions
33
clients/algoliasearch-client-dart/packages/chopper_requester/lib/src/auth_interceptor.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import 'dart:async' show FutureOr; | ||
|
||
import 'package:chopper/chopper.dart'; | ||
|
||
/// Interceptor that attaches the application id and API key to outgoing requests. | ||
/// | ||
/// This interceptor modifies the headers of each request to include the | ||
/// application id and API key for Algolia authentication. | ||
class AuthInterceptor implements Interceptor { | ||
/// The application id used for Algolia authentication. | ||
final String appId; | ||
|
||
/// The API key used for Algolia authentication. | ||
final String apiKey; | ||
|
||
/// Constructs an [AuthInterceptor] with the provided application id and API key. | ||
const AuthInterceptor({ | ||
required this.appId, | ||
required this.apiKey, | ||
}); | ||
|
||
@override | ||
FutureOr<Response<BodyType>> intercept<BodyType>(Chain<BodyType> chain) => | ||
chain.proceed( | ||
applyHeaders( | ||
chain.request, | ||
{ | ||
'x-algolia-application-id': appId, | ||
'x-algolia-api-key': apiKey, | ||
}, | ||
), | ||
); | ||
} |
109 changes: 109 additions & 0 deletions
109
clients/algoliasearch-client-dart/packages/chopper_requester/lib/src/chopper_requester.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
import 'dart:async' show TimeoutException; | ||
|
||
import 'package:algolia_client_core/algolia_client_core.dart'; | ||
import 'package:chopper/chopper.dart'; | ||
import 'package:algolia_chopper_requester/src/agent_interceptor.dart'; | ||
import 'package:algolia_chopper_requester/src/auth_interceptor.dart'; | ||
import 'package:algolia_chopper_requester/src/platform/platform.dart'; | ||
import 'package:algolia_chopper_requester/src/version.dart'; | ||
import 'package:http/http.dart' as http; | ||
import 'package:logging/logging.dart' show Logger; | ||
|
||
/// A [Requester] implementation using the Chopper library. | ||
/// | ||
/// This class sends HTTP requests using the Chopper library and handles | ||
/// response conversion and error handling. | ||
class ChopperRequester implements Requester { | ||
/// The underlying Chopper client. | ||
final ChopperClient _client; | ||
|
||
/// Constructs a [ChopperClient] with the given [appId] and [apiKey]. | ||
ChopperRequester({ | ||
required String appId, | ||
required String apiKey, | ||
Map<String, dynamic>? headers, | ||
Iterable<AgentSegment>? clientSegments, | ||
Logger? logger, | ||
Iterable<Interceptor>? interceptors, | ||
http.Client? client, | ||
}) : _client = ChopperClient( | ||
client: client, | ||
converter: JsonConverter(), | ||
interceptors: [ | ||
AuthInterceptor( | ||
appId: appId, | ||
apiKey: apiKey, | ||
), | ||
AgentInterceptor( | ||
agent: AlgoliaAgent(packageVersion) | ||
..addAll([ | ||
...?clientSegments, | ||
...Platform.agentSegments(), | ||
]), | ||
), | ||
if (logger != null) | ||
HttpLoggingInterceptor( | ||
level: Level.body, | ||
onlyErrors: false, | ||
logger: logger, | ||
), | ||
...?interceptors, | ||
], | ||
); | ||
|
||
@override | ||
Future<HttpResponse> perform(HttpRequest request) async { | ||
try { | ||
final Response<Map<String, dynamic>> response = await execute(request); | ||
|
||
if (response.isSuccessful) { | ||
return HttpResponse( | ||
response.statusCode, | ||
response.body, | ||
); | ||
} else { | ||
throw AlgoliaApiException( | ||
response.statusCode, | ||
response.error ?? response.body, | ||
); | ||
} | ||
} on TimeoutException catch (e) { | ||
throw AlgoliaTimeoutException(e); | ||
} on http.ClientException catch (e) { | ||
throw AlgoliaIOException(e); | ||
} | ||
} | ||
|
||
/// Executes the [request] and returns the response as an [HttpResponse]. | ||
Future<Response<Map<String, dynamic>>> execute(HttpRequest request) async { | ||
final Request chopperRequest = Request( | ||
request.method, | ||
Uri( | ||
scheme: request.host.scheme, | ||
host: request.host.url, | ||
port: request.host.port, | ||
path: request.path, | ||
), | ||
_client.baseUrl, | ||
body: request.body, | ||
parameters: request.queryParameters, | ||
headers: { | ||
for (final MapEntry<String, dynamic> entry | ||
in request.headers?.entries ?? const {}) | ||
entry.key: entry.value.toString(), | ||
if (request.body != null) 'content-type': 'application/json', | ||
}, | ||
); | ||
|
||
return switch (options.timeout) { | ||
null => await _client | ||
.send<Map<String, dynamic>, Map<String, dynamic>>(chopperRequest), | ||
_ => await _client | ||
.send<Map<String, dynamic>, Map<String, dynamic>>(chopperRequest) | ||
.timeout(options.timeout!), | ||
}; | ||
} | ||
|
||
@override | ||
void close() => _client.dispose(); | ||
} |
17 changes: 17 additions & 0 deletions
17
clients/algoliasearch-client-dart/packages/chopper_requester/lib/src/platform/platform.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import 'package:algolia_client_core/algolia_client_core.dart'; | ||
import 'package:chopper/chopper.dart'; | ||
|
||
import 'platform_stub.dart' | ||
if (dart.library.html) 'platform_web.dart' | ||
if (dart.library.io) 'platform_io.dart'; | ||
|
||
final class Platform { | ||
/// Get [AgentSegment]s for the current platform. | ||
static Iterable<AgentSegment> agentSegments() => platformAgentSegments(); | ||
|
||
/// Set Algolia Agent as User-Agent or as query param depending on the platform. | ||
static Request algoliaAgent<T>(Chain<T> chain, String agent) => | ||
platformAlgoliaAgent(chain, agent); | ||
|
||
Platform._(); | ||
} |
20 changes: 20 additions & 0 deletions
20
...ts/algoliasearch-client-dart/packages/chopper_requester/lib/src/platform/platform_io.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import 'dart:io' as io; | ||
|
||
import 'package:algolia_client_core/algolia_client_core.dart'; | ||
import 'package:chopper/chopper.dart'; | ||
|
||
/// [AgentSegment]s for native platforms. | ||
Iterable<AgentSegment> platformAgentSegments() => [ | ||
AgentSegment( | ||
value: 'Dart', | ||
version: io.Platform.version, | ||
), | ||
AgentSegment( | ||
value: io.Platform.operatingSystem, | ||
version: io.Platform.operatingSystemVersion, | ||
), | ||
]; | ||
|
||
/// [AlgoliaAgent] for native platforms as user-agent. | ||
Request platformAlgoliaAgent<T>(Chain<T> chain, String agent) => | ||
applyHeader(chain.request, "user-agent", agent); |
11 changes: 11 additions & 0 deletions
11
.../algoliasearch-client-dart/packages/chopper_requester/lib/src/platform/platform_stub.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import 'package:algolia_client_core/algolia_client_core.dart'; | ||
import 'package:chopper/chopper.dart'; | ||
|
||
/// [AgentSegment]s for unsupported platforms. | ||
Iterable<AgentSegment> platformAgentSegments() => const []; | ||
|
||
/// [AlgoliaAgent] for unsupported platforms. | ||
Request platformAlgoliaAgent<T>(Chain<T> chain, String agent) { | ||
// NO-OP. | ||
return chain.request; | ||
} |
20 changes: 20 additions & 0 deletions
20
...s/algoliasearch-client-dart/packages/chopper_requester/lib/src/platform/platform_web.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import 'dart:html' as web; | ||
|
||
import 'package:algolia_client_core/algolia_client_core.dart'; | ||
import 'package:chopper/chopper.dart'; | ||
|
||
/// [AgentSegment]s for web platforms. | ||
Iterable<AgentSegment> platformAgentSegments() => [ | ||
AgentSegment( | ||
value: 'Platform', | ||
version: 'Web ${web.window.navigator.platform}', | ||
), | ||
]; | ||
|
||
Request platformAlgoliaAgent<T>(Chain<T> chain, String agent) => | ||
chain.request.copyWith( | ||
parameters: { | ||
...chain.request.parameters, | ||
'X-Algolia-Agent': agent, | ||
}, | ||
); |
2 changes: 2 additions & 0 deletions
2
clients/algoliasearch-client-dart/packages/chopper_requester/lib/src/version.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/// Current package version | ||
const packageVersion = '1.0.0'; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.