You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source"$HOME/.cargo/env"
Build and test
# build examples libraries
make
# run nginx
make run
# or specify nginx executable file path# make run NGINX_BIN=/path/to/nginx# in another terminal# curl the tests
make test
Library Skelton
#[no_mangle]pubextern"C"fnlibffi_init(cfg:*mutc_char,tq:*constc_void) -> c_int{let cfg = unsafe{CStr::from_ptr(cfg).to_string_lossy()};let cfg = serde_json::from_str::<Value>(&cfg);if !cfg.is_ok(){return1;}let cfg:Value = cfg.unwrap();let tq = TaskQueueHandle(tq);
thread::spawn(move || {println!("cfg: {:?}", cfg);let tq = tq.clone();let nullptr = std::ptr::null_mut();loop{unsafe{// poll a tasklet task = ngx_http_lua_ffi_task_poll(tq.0);// if the task queue is done, then quitif task.is_null(){break;}// get the request from the tasklet req = ngx_http_lua_ffi_get_req(task, nullptr);// copy the request as response, allocated by C strdup()// note that both request and response would be freed by nginxlet res = libc::strdup(req);ngx_http_lua_ffi_respond(task,0, res,0);}}println!("exit echo runtime");});return0;}