Skip to content
This repository has been archived by the owner on Jul 2, 2024. It is now read-only.

Commit

Permalink
Interception fix for Web Admin
Browse files Browse the repository at this point in the history
  • Loading branch information
blazern committed Nov 25, 2021
1 parent 4004beb commit b3ba707
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lib/utils/HttpHelper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ import 'OpenFoodAPIConfiguration.dart';
import 'QueryType.dart';

abstract class HttpInterceptor {
Future<http.Request?> interceptGet(Uri uri);
Future<http.Request?> interceptPost(Uri uri);
Future<http.MultipartRequest?> interceptMultipart(String method, Uri uri);
Future<http.Request>? interceptGet(Uri uri);
Future<http.Response>? fullyInterceptGet(Uri uri);
Future<http.Request>? interceptPost(Uri uri);
Future<http.MultipartRequest>? interceptMultipart(String method, Uri uri);
}

/// General functions for sending http requests (post, get, multipart, ...)
Expand All @@ -38,6 +39,11 @@ class HttpHelper {
UserAgent? userAgent,
QueryType? queryType,
}) async {
final fullInterception = await interceptor?.fullyInterceptGet(uri);
if (fullInterception != null) {
return fullInterception;
}

var request = await interceptor?.interceptGet(uri);
request ??= http.Request('GET', uri);
request.headers.addAll(
Expand Down

0 comments on commit b3ba707

Please sign in to comment.