Skip to content

Commit

Permalink
add setDynamicdata method
Browse files Browse the repository at this point in the history
  • Loading branch information
Gsantomaggio committed Feb 25, 2021
1 parent b53730d commit f6e39ad
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
6 changes: 3 additions & 3 deletions bazel/repository_locations.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -921,10 +921,10 @@ REPOSITORY_LOCATIONS_SPEC = dict(
project_name = "WebAssembly for Proxies (C++ host implementation)",
project_desc = "WebAssembly for Proxies (C++ host implementation)",
project_url = "https://github.com/proxy-wasm/proxy-wasm-cpp-host",
version = "d1a2a7db59a72edacc9a6286b64280b72767d2d0",
sha256 = "3e81235c963291bd01f9425ed6e34d6b44ca0adc9f281b0cafc5cba6ad3bcc6d",
version = "dcfce2c319b26bd9109edd905d69f35e0b7cbc8e",
sha256 = "7ef0b220769b7ba536df40954451cb333822053e7030eff194e4a911472dc7d2",
strip_prefix = "proxy-wasm-cpp-host-{version}",
urls = ["https://github.com/proxy-wasm/proxy-wasm-cpp-host/archive/{version}.tar.gz"],
urls = ["https://github.com/Gsantomaggio/proxy-wasm-cpp-host/archive/{version}.tar.gz"],
use_category = ["dataplane_ext"],
extensions = [
"envoy.access_loggers.wasm",
Expand Down
16 changes: 16 additions & 0 deletions source/extensions/common/wasm/context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1120,6 +1120,22 @@ const Network::Connection* Context::getConnection() const {
return nullptr;
}

WasmResult Context::setDynamicdata(absl::string_view path, absl::string_view value) {
auto* stream_info = getRequestStreamInfo();
if (!stream_info) {
return WasmResult::NotFound;
}
std::string key;
absl::StrAppend(&key, path);
ProtobufWkt::Struct metadata_val;
// auto& fields_a = *metadata_val.mutable_fields();
std::string metadata_value;
absl::StrAppend(&metadata_value, value);

stream_info->setDynamicMetadata(key, metadata_val);
return WasmResult::Ok;
}

WasmResult Context::setProperty(absl::string_view path, absl::string_view value) {
auto* stream_info = getRequestStreamInfo();
if (!stream_info) {
Expand Down
2 changes: 2 additions & 0 deletions source/extensions/common/wasm/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,8 @@ class Context : public proxy_wasm::ContextBase,
// State accessors
WasmResult getProperty(absl::string_view path, std::string* result) override;
WasmResult setProperty(absl::string_view path, absl::string_view value) override;
WasmResult setDynamicdata(absl::string_view path, absl::string_view value) override;

WasmResult declareProperty(absl::string_view path,
Filters::Common::Expr::CelStatePrototypeConstPtr state_prototype);

Expand Down

0 comments on commit f6e39ad

Please sign in to comment.