@@ -22,11 +22,15 @@ typedef enum {
2222 envoy_dynamic_module_type_http_header_type_ResponseTrailer = 3,
2323} envoy_dynamic_module_type_http_header_type;
2424
25+ // envoy_dynamic_module_type_envoy_buffer is a struct representing a buffer owned by Envoy.
26+ // Uses const char* because this receives data FROM Envoy.
2527typedef struct {
26- uintptr_t ptr;
28+ const char* ptr;
2729 size_t length;
2830} envoy_dynamic_module_type_envoy_buffer;
2931
32+ // envoy_dynamic_module_type_module_buffer is a struct representing a buffer owned by the module.
33+ // Uses uintptr_t because this sends data TO Envoy.
3034typedef struct {
3135 uintptr_t ptr;
3236 size_t length;
@@ -85,8 +89,7 @@ size_t envoy_dynamic_module_callback_http_get_body_chunks_size(
8589 int body_type);
8690
8791#cgo noescape envoy_dynamic_module_callback_http_send_response
88- // Uncomment once https://github.com/envoyproxy/envoy/pull/39206 is merged.
89- // #cgo nocallback envoy_dynamic_module_callback_http_send_response
92+ #cgo nocallback envoy_dynamic_module_callback_http_send_response
9093void envoy_dynamic_module_callback_http_send_response(
9194 uintptr_t filter_envoy_ptr, uint32_t status_code,
9295 uintptr_t headers_vector, size_t headers_vector_size,
@@ -164,13 +167,11 @@ func envoy_dynamic_module_on_program_init() uintptr {
164167//export envoy_dynamic_module_on_http_filter_config_new
165168func envoy_dynamic_module_on_http_filter_config_new (
166169 _ uintptr ,
167- namePtr * C.char ,
168- nameSize C.size_t ,
169- configPtr * C.char ,
170- configSize C.size_t ,
170+ nameBuffer C.envoy_dynamic_module_type_envoy_buffer ,
171+ configBuffer C.envoy_dynamic_module_type_envoy_buffer ,
171172) uintptr {
172- name := C .GoStringN (namePtr , C .int (nameSize ))
173- config := C .GoBytes (unsafe .Pointer (configPtr ), C .int (configSize ))
173+ name := C .GoStringN (nameBuffer . ptr , C .int (nameBuffer . length ))
174+ config := C .GoBytes (unsafe .Pointer (configBuffer . ptr ), C .int (configBuffer . length ))
174175 filterConfig := NewHttpFilterConfig (name , config )
175176 if filterConfig == nil {
176177 return 0
@@ -389,7 +390,7 @@ func (e envoyFilter) GetRequestHeader(key string) (string, bool) {
389390 return "" , false
390391 }
391392
392- result := unsafe .Slice ((* byte )(unsafe .Pointer (uintptr ( resultBuf .ptr ) )), resultBuf .length )
393+ result := unsafe .Slice ((* byte )(unsafe .Pointer (resultBuf .ptr )), resultBuf .length )
393394 runtime .KeepAlive (key )
394395 return string (result ), true
395396}
@@ -415,7 +416,7 @@ func (e envoyFilter) GetResponseHeader(key string) (string, bool) {
415416 return "" , false
416417 }
417418
418- result := unsafe .Slice ((* byte )(unsafe .Pointer (uintptr ( resultBuf .ptr ) )), resultBuf .length )
419+ result := unsafe .Slice ((* byte )(unsafe .Pointer (resultBuf .ptr )), resultBuf .length )
419420 runtime .KeepAlive (key )
420421 return string (result ), true
421422}
@@ -563,7 +564,7 @@ func (e envoyFilter) getStringAttribute(id int) string {
563564 if ! ret {
564565 return ""
565566 }
566- return string (unsafe .Slice ((* byte )(unsafe .Pointer (uintptr ( result .ptr ) )), result .length )) // Copy the result to a Go string.
567+ return string (unsafe .Slice ((* byte )(unsafe .Pointer (result .ptr )), result .length )) // Copy the result to a Go string.
567568}
568569
569570// GetRequestHeaders implements EnvoyHttpFilter.
0 commit comments