I have found it's easy to use node-http-proxy to route a sub-directory to different ports on a local server. However, I haven't found if there's a way to run a custom function when doing the routing. What I want to do is:
- If the service on the target port is not running, start it up, then finish the route
- If the service is already running on the target port, just do the route
I'm not asking about how to check for the service and start it, just how to have a function called each time a re-route is going to take place.
Can I do something like this?
var options = {
route: {
'/task1' : customFunc('3000'),
'/task2' : customFunc('3001'),
}
}
httpProxy.createServer(options).listen(80);