option.router with callback in arguments
See original GitHub issueHi, thanks for awesome library. I’m trying to use it as proxy for app but I have to do async actions to resolve new target.
It would be great to have possibility to do something like this:
var apiProxy = proxy('/api', {
target: 'http://localhost:1234',
router: function (req, callback) {
myAsyncApi()
.then(function(newTarget){
callback('newTarget');
})
}
});
Issue Analytics
- State:
- Created 7 years ago
- Reactions:16
- Comments:13 (3 by maintainers)
Top Results From Across the Web
How to pass arguments to a callback function in express?
1 Answer 1 ; function verification(arg1, arg2, req, res, next) {...} router. ; post · '/item/:id/dosomething', verification.bind( ; post · '/item/:id ...
Read more >callback-router - npm
Determines which routes match the pathname and invokes their callbacks. Returns the value returned from the callback of the highest-priority ( ...
Read more >Routing - Express.js
In fact, the routing methods can have more than one callback function as arguments. With multiple callback functions, it is important to provide...
Read more >Express.js router.param() function - GeeksforGeeks
Basically router.param() function triggers the callback function whenever user routes to the parameter. This callback function will be called ...
Read more >Express Tutorial Part 4: Routes and controllers - MDN Web Docs
The router function above takes a single callback, but you can specify as many callback arguments as you want, or an array of...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thank you for the kind words.
Never thought of the be used this way.
Will consider adding it if more users have to need for this.
I can achieve my goal by adding middleware before proxy to do that asynchronous actions before and keep ‘newTarget’ in req object. But still I would be nice to have ‘callback’ in arguments.