warpgate_pdk 0.17.0

Reusable WASM macros and functions for plugin developer kits.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use extism_pdk::{MemoryHandle, memory::internal::load};
use warpgate_api::SendRequestOutput;

/// Populate the body of a [`SendRequestOutput`] by loading the raw bytes
/// from WASM memory, using the body offset and length.
#[doc(hidden)]
pub fn populate_send_request_output(output: &mut SendRequestOutput) {
    if output.body.is_empty() {
        let handle = unsafe { MemoryHandle::new(output.body_offset, output.body_length) };
        let mut body = vec![0; handle.length as usize];

        load(handle, &mut body);

        output.body = body;
    }
}