proxy-wasm-cpp-sdk
proxy-wasm-cpp-sdk copied to clipboard
how to read file in wasm
In the wasm filter ,I want to read some configurations from file. I wrote some code in the onConfigure part like this
std::string data;
std::ifstream infile;
infile.open("/configurations.json");
infile >> data;;
infile.close();
LOG_ERROR("configurations -> " + data);
Howerev, I cannot get any content of the configuration file.
How to read a configuration file in wasm ? Is there a file read API in the proxy-wasm-cpp-sdk?
Ths.
Host does not yet support file read ABI: https://github.com/proxy-wasm/proxy-wasm-cpp-host/issues/127
The read-only file access is being actively worked on... But why exactly do you need it?
Note that the recommended way to configure plugins is to add the configuration in the proxy config itself, which is then available in the plugin via proxy_get_buffer_bytes(WasmBufferType::PluginConfiguration, ...)
.
The read-only file access is being actively worked on... But why exactly do you need it?
Note that the recommended way to configure plugins is to add the configuration in the proxy config itself, which is then available in the plugin via
proxy_get_buffer_bytes(WasmBufferType::PluginConfiguration, ...)
.
This kind of requirement is more common, for example, we use wasm to do some traffic processing work, which will involve policy reading, so we need to read the mounted configuration from the envoy proxy
@PiotrSikora In addition,If the policy is complex and confidential, it is obviously not wise to put it all in the proxy configuration