Jaumard 7d5695e551
dart-dio improvements (#6047)
* fix runtime deserialisation

* add security support for dart dio

* regenerate dart dio sample

* update dio pubspec.mustache deps

* check response type before parsing

* add default dateTime serializer

* regenerate sample
2020-05-02 21:23:52 +08:00

24 lines
729 B
Dart

import 'dart:async';
import 'package:dio/dio.dart';
abstract class AuthInterceptor extends Interceptor {
/*
* Get auth information on given route for the given type
* Can return null if type is not present on auth data or if route doesn't need authentication
*/
List<Map<String, dynamic>> getAuthInfo(RequestOptions route, String type) {
if (route.extra.containsKey("secure")) {
final auth = route.extra["secure"];
List<Map<String, dynamic>> results = [];
for (var info in auth) {
if(info["type"] == type) {
results.add(info);
}
}
return results;
}
return [];
}
}