tetratelabs / proxy-wasm-go-sdk

WebAssembly for Proxies (Go SDK)
Apache License 2.0
687 stars 151 forks source link

provide json package alternative #36

Closed mathetake closed 4 years ago

mathetake commented 4 years ago

somewhat related to #12

mathetake commented 4 years ago

After TinyGo supports WASI, we could use https://github.com/vugu/vjson

mathetake commented 4 years ago
func (ctx context) OnVMStart(vmConfigurationSize int) bool {
    data, err := proxywasm.HostCallGetVMConfiguration(vmConfigurationSize)
    if err != nil {
        proxywasm.LogCritical("error reading vm configuration", err.Error())
    }

    var c map[string]interface{}
    if err := vjson.Unmarshal(data, &c); err != nil {
        panic(err)
    }

    proxywasm.LogInfo("vm config: \n", c["name"].(string))
    return true
}

verified that it works with WASI target:

[2020-09-14 17:44:43.371][1014652][info][wasm] [external/envoy/source/extensions/common/wasm/context.cc:997] wasm log my_root_id: vm config:
vm configuration