proxy-wasm-rust-sdk icon indicating copy to clipboard operation
proxy-wasm-rust-sdk copied to clipboard

How to handle HTTP request callback in "on_tick" method

Open pjjwpc opened this issue 3 years ago • 1 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(); } }

pjjwpc avatar Aug 26 '22 05:08 pjjwpc


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(...);
    }

}

ismailbaskin avatar Sep 21 '22 20:09 ismailbaskin

thanks @ismailbaskin

pjjwpc avatar Nov 15 '22 08:11 pjjwpc