Skip to content
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

Is it possible to make HTTP call from fn on_http_request_headers method? #171

Open
iandrosov opened this issue Nov 1, 2022 · 1 comment

Comments

@iandrosov
Copy link

Use case for this is custom Auth policy for Envoy often needs to make additional validation HTTP requests to IDP services as example to validate header values or possibly chain 2 calls to get final OK to Continue.

Looking at on_http_request_headers function and Rust HTTP Client calls it seem those are not compatible even if we use reqwest::blocking::Client. Is this something that can be done in the context of WASM custom policy for Envoy or NOT?
Using this sample code inside a function while it works in Rust code it does not seem to be compatible with proxi-wasm ABI

let client = Client::new();
let resp = client.post("http://httpbin.org/post")
.body("Send secret code to validate")
.send()?;
if resp.status() == StatusCode::OK {
println!("RESULT 200");
return Action::Continue;
}else{
println!("RESULT ERROR");
}

This code cannot compile due to errors like this one of them cannot use the ? operator in a method that returns proxy_wasm::types::Action

@PiotrSikora
Copy link
Contributor

It possible to make HTTP calls (see: examples/http_auth_random.rs), but not using reqwest::blocking::Client.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants