express-request-proxy icon indicating copy to clipboard operation
express-request-proxy copied to clipboard

[Feature Request] Intercept request before sending

Open muymoo opened this issue 7 years ago • 0 comments

I am writing zipkin client instrumentation for express-request-proxy . I need a way to intercept the request so I can record it before it is sent and then intercept the response (transformers will probably work for the response).

I've already instrumented plain old request (https://github.com/openzipkin/zipkin-js/tree/master/packages/zipkin-instrumentation-request) so if there was a way to pass in a modified request to express-request-proxy like:

const request = require('request');
const wrapRequest = require('zipkin-instrumentation-request');
const proxy = require('express-request-proxy');

const wrappedRequest = wrapRequest(request, {tracer, serviceName, remoteServiceName});
app.get(proxy({url:'http://api.weather.com'}, wrappedRequest);

it would make my life a lot easier. This could also be used if others want to pass in a request.defaults() instance for express-request-proxy to use.

Another option would be to have decorateRequest like express-http-proxy has which I used here (https://github.com/openzipkin/zipkin-js/blob/master/packages/zipkin-instrumentation-express/src/wrapExpressHttpProxy.js) when instrumenting that client.

muymoo avatar Mar 24 '17 16:03 muymoo