Is this a feature request?
Yes. I would like a pathRewrite function that returns a Promise to be handled. Currently it can only return a string.
My use case is: when a request for /api/foo?auth_token=xxx arrives, I need to:
- Grab
auth_token and check its validity. This is an async operation
- If it is valid, use the token to look up some additional information that token has permission to access in a database (also an async operation)
- Assuming all goes well, return a rewritten path, like
/other-api/bar?db-field-1=abc&db-field-2=abc. If it did not go well, the path will be rewritten to /other-api/404
Similar to #318, but this covers the case where more than just the response headers/status needs to be modified.
I have this working and tested in a local fork, please let me know if you would accept a PR.
Is this a feature request?
Yes. I would like a
pathRewritefunction that returns aPromiseto be handled. Currently it can only return astring.My use case is: when a request for
/api/foo?auth_token=xxxarrives, I need to:auth_tokenand check its validity. This is an async operation/other-api/bar?db-field-1=abc&db-field-2=abc. If it did not go well, the path will be rewritten to/other-api/404Similar to #318, but this covers the case where more than just the response headers/status needs to be modified.
I have this working and tested in a local fork, please let me know if you would accept a PR.