mirror of
https://github.com/wanghongenpin/proxypin.git
synced 2026-03-27 06:39:45 +08:00
24 lines
713 B
Dart
24 lines
713 B
Dart
import 'package:proxypin/network/channel/host_port.dart';
|
|
import 'package:proxypin/network/http/http.dart';
|
|
|
|
/// A Interceptor that can intercept and modify the request and response.
|
|
/// @author Hongen Wang
|
|
abstract class Interceptor {
|
|
/// The priority of the interceptor.
|
|
int get priority => 0;
|
|
|
|
Future<HostAndPort> preConnect(HostAndPort hostAndPort) async {
|
|
return hostAndPort;
|
|
}
|
|
|
|
/// Called before the request is sent to the server.
|
|
Future<HttpRequest?> onRequest(HttpRequest request) async {
|
|
return request;
|
|
}
|
|
|
|
/// Called after the response is received from the server.
|
|
Future<HttpResponse?> onResponse(HttpRequest request, HttpResponse response) async {
|
|
return response;
|
|
}
|
|
}
|