Adding interceptors to Netable will be necessary for working with our mocking libraries.
I think we can be pretty flexible here and offload most of the work to the actual interceptors, but we need to provide something at the base level to allow interceptors to interface with Netable.
I think a good starting place might be:
-
Introduce new top level types called Interceptor and RequestInterceptor that look something like
struct Interceptor {
let interceptors: [RequestInterceptor]
}
protocol RequestInterceptor {
func adapt(_ request: URLRequest, instance: Netable) async throws -> URLRequest {}
}
-
Add optional parameters to both Netable.init and Netable.request that accept an Interceptor
-
Modify request to apply any interceptors to our URLRequest before it gets sent off
Adding interceptors to Netable will be necessary for working with our mocking libraries.
I think we can be pretty flexible here and offload most of the work to the actual interceptors, but we need to provide something at the base level to allow interceptors to interface with Netable.
I think a good starting place might be:
Introduce new top level types called
InterceptorandRequestInterceptorthat look something likeAdd optional parameters to both
Netable.initandNetable.requestthat accept anInterceptorModify
requestto apply any interceptors to ourURLRequestbefore it gets sent off