diff --git a/plugins/wasm-go/pkg/wrapper/plugin_wrapper.go b/plugins/wasm-go/pkg/wrapper/plugin_wrapper.go index 5c92a5a2d..1ad9bb3da 100644 --- a/plugins/wasm-go/pkg/wrapper/plugin_wrapper.go +++ b/plugins/wasm-go/pkg/wrapper/plugin_wrapper.go @@ -73,6 +73,8 @@ type HttpContext interface { SetRequestBodyBufferLimit(byteSize uint32) // Note that this parameter affects the gateway's memory usage! Support setting a maximum buffer size for each response body individually in response phase. SetResponseBodyBufferLimit(byteSize uint32) + // Get contextId of HttpContext + GetContextId() uint32 } type oldParseConfigFunc[PluginConfig any] func(json gjson.Result, config *PluginConfig, log Log) error @@ -673,6 +675,10 @@ func (ctx *CommonHttpCtx[PluginConfig]) SetResponseBodyBufferLimit(size uint32) _ = proxywasm.SetProperty([]string{"set_encoder_buffer_limit"}, []byte(strconv.Itoa(int(size)))) } +func (ctx *CommonHttpCtx[PluginConfig]) GetContextId() uint32 { + return ctx.contextID +} + func (ctx *CommonHttpCtx[PluginConfig]) OnHttpRequestHeaders(numHeaders int, endOfStream bool) types.Action { requestID, _ := proxywasm.GetHttpRequestHeader("x-request-id") _ = proxywasm.SetProperty([]string{"x_request_id"}, []byte(requestID))