-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How do I get http_call_response #257
Comments
Use Try |
I see the contract in the base context trait, e.g.:
Is this what you are referering to? is there a way to get the response else where? other than in the context For example I have a client called depdendenClient, and I need to dispatch a http call and getting a response body back then modify the request header |
@antonengelhardt yes! this is the one I am talking about. However, is there another way to handle this outside of the context? Reason being we have several outbound calls rely on the dispatch_http_call before send it to upstream |
@alexhu20 Do you need to make several calls for each request or once (at the beginning/when the filter starts)? |
We do make several calls for each request, and rely on the result then determine whether continue with the upstream or terminate send response back to the downstream |
@alexhu20 You get the token id when you dispatch a call, you can store it in the context struct and you will also get the token id when the response callback is executed. Then you can match it and handle the request furthermore. Alternatively, you can store the state as an enum in the context struct and work with that. For both methods, you can check my pinned repo. |
I have something with registering a callback map HashMap<u32, Box>, and the
In this something you'd advise to do so? |
I am not really sure if this works... You can dispatch multiple calls in any implementation of |
Hello, @alexhu20 , I also encountered a similar problem to yours, and referring to asynchronous programming implementations in other languages, I think JavaScript's Promise is very suitable for this scenario (single-threaded execution, driven by other runtime's event loops). Therefore, I implemented this programming paradigm in proxy-wasm and submitted a PR. You can see if the implementation here meets your needs #265 |
Description
I have use case that need to make a separate http call in wasm and getting a response back. I only see that the base context has an API called
on_http_call_response
to fetch the entire response body.Is there a way to do so in my client implementation?
Another question:
The response body example seems incorrect, I have to do the following in order to buffer the entire response body, am I doing it wrong?
The text was updated successfully, but these errors were encountered: