proxy-wasm / proxy-wasm-rust-sdk

WebAssembly for Proxies (Rust SDK)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to handle HTTP request callback in "on_tick" method

pjjwpc opened this issue · comments

fn on_tick(&mut self) {
unsafe {
self.dispatch_http_call(
&VM_CONFIG_GLBOAL.gatewaycluster,
vec![
(":method", "GET"),
(
":path",
"/hello",
),
(":authority","hello"),
],
None,
vec![],
Duration::from_secs(1),
)
.unwrap();
}
}

impl Context for PluginRootContext {
    fn on_http_call_response(&mut self, _token_id: u32, _num_headers: usize, _body_size: usize, _num_trailers: usize) {
        /*
        The code that handles dispatched http response
         */
    }
}

impl RootContext for PluginRootContext {
    fn on_tick(&mut self) {
        self.dispatch_http_call(...);
    }

}