Open benhathaway opened 7 years ago
Hasn't it been fixed yet?
What I'm trying is:
this.client.configure(x => {
x.withInterceptor({
request: msg => {
if (...) {
return new Response(...); // This doesn't seem to short-circuit the request process
}
return msg;
}
});
});
and it doesn't work...
aurelia-http-client 1.3.0
There is an asymmetry between interceptors in the http-client module and the http-fetch module.
The http-fetch module has the option to short-circuit the request/response process using an interceptor. You can return a
Response
object (or aPromise<Response>
) from a request interceptor method and the fetch module will simply treat that response as the result of the process and switch directly to the response half of the pipeline (chain) without actually making any network calls.This functionality is missing from the equivalent http-client module. This is clearly an unintentional asymmetry - and a feature that I will find very useful when writing a request batching plugin. It also looks to be only a couple of lines to change, so I intend to offer a pull request.