mirror of
https://github.com/austinried/subtracks.git
synced 2026-02-10 15:02:42 +01:00
v2
This commit is contained in:
24
lib/http/client.dart
Normal file
24
lib/http/client.dart
Normal file
@@ -0,0 +1,24 @@
|
||||
import 'package:http/http.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
|
||||
part 'client.g.dart';
|
||||
|
||||
const Map<String, String> subtracksHeaders = {
|
||||
'user-agent': 'subtracks/android',
|
||||
};
|
||||
|
||||
class SubtracksHttpClient extends BaseClient {
|
||||
SubtracksHttpClient();
|
||||
|
||||
@override
|
||||
Future<StreamedResponse> send(BaseRequest request) {
|
||||
request.headers.addAll(subtracksHeaders);
|
||||
print('${request.method} ${request.url}');
|
||||
return request.send();
|
||||
}
|
||||
}
|
||||
|
||||
@Riverpod(keepAlive: true)
|
||||
BaseClient httpClient(HttpClientRef ref) {
|
||||
return SubtracksHttpClient();
|
||||
}
|
||||
23
lib/http/client.g.dart
Normal file
23
lib/http/client.g.dart
Normal file
@@ -0,0 +1,23 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'client.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// RiverpodGenerator
|
||||
// **************************************************************************
|
||||
|
||||
String _$httpClientHash() => r'78f604dbc249a854728d71bde8289d48f6700be7';
|
||||
|
||||
/// See also [httpClient].
|
||||
@ProviderFor(httpClient)
|
||||
final httpClientProvider = Provider<BaseClient>.internal(
|
||||
httpClient,
|
||||
name: r'httpClientProvider',
|
||||
debugGetCreateSourceHash:
|
||||
const bool.fromEnvironment('dart.vm.product') ? null : _$httpClientHash,
|
||||
dependencies: null,
|
||||
allTransitiveDependencies: null,
|
||||
);
|
||||
|
||||
typedef HttpClientRef = ProviderRef<BaseClient>;
|
||||
// ignore_for_file: unnecessary_raw_strings, subtype_of_sealed_class, invalid_use_of_internal_member, do_not_use_environment, prefer_const_constructors, public_member_api_docs, avoid_private_typedef_functions
|
||||
Reference in New Issue
Block a user