|
@@ -1,6 +1,12 @@
|
|
|
+import 'package:fis_jsonrpc/request.dart';
|
|
|
+
|
|
|
import 'exception.dart';
|
|
|
|
|
|
abstract class JsonRpcInterceptor {
|
|
|
+ Future<JsonRpcRequest> onRequestTransmit(JsonRpcRequest request) async {
|
|
|
+ return request;
|
|
|
+ }
|
|
|
+
|
|
|
Future<Map<String, dynamic>> onResponse(Map<String, dynamic> response) async {
|
|
|
return response;
|
|
|
}
|
|
@@ -21,6 +27,15 @@ class _JsonRpcInterceptHost implements JsonRpcInterceptor {
|
|
|
_interceptors.add(interceptor);
|
|
|
}
|
|
|
|
|
|
+ @override
|
|
|
+ Future<JsonRpcRequest> onRequestTransmit(JsonRpcRequest request) async {
|
|
|
+ var pipeVal = request;
|
|
|
+ for (var interceptor in _interceptors) {
|
|
|
+ pipeVal = await interceptor.onRequestTransmit(pipeVal);
|
|
|
+ }
|
|
|
+ return pipeVal;
|
|
|
+ }
|
|
|
+
|
|
|
@override
|
|
|
Future<Map<String, dynamic>> onResponse(Map<String, dynamic> response) async {
|
|
|
var pipeVal = response;
|